2019-05-30 02:12:11 +00:00
|
|
|
|
2019-05-31 19:05:33 +00:00
|
|
|
/**
|
|
|
|
AstroLibre
|
|
|
|
An open source Bally Astrocade BIOS implementation in C
|
|
|
|
by Steven Hugg (@sehugg) for 8bitworkshop.com
|
2018-09-05 02:28:12 +00:00
|
|
|
|
2019-05-31 19:05:33 +00:00
|
|
|
To the extent possible under law, the author(s) have
|
|
|
|
dedicated all copyright and related and neighboring
|
|
|
|
rights to this software to the public domain worldwide.
|
|
|
|
This software is distributed without any warranty.
|
|
|
|
|
|
|
|
See: http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
**/
|
|
|
|
|
|
|
|
//#resource "astrocade.inc"
|
|
|
|
//#link "biosasm.s"
|
|
|
|
|
2019-06-01 22:12:34 +00:00
|
|
|
// demo code
|
2019-05-31 19:05:33 +00:00
|
|
|
//#link "test1.s"
|
2018-09-05 02:28:12 +00:00
|
|
|
|
2019-06-02 02:09:45 +00:00
|
|
|
// music processor
|
|
|
|
//#link "bmusic.c"
|
|
|
|
|
2019-06-02 14:53:39 +00:00
|
|
|
// input
|
|
|
|
//#link "input.c"
|
|
|
|
|
|
|
|
// graphics
|
|
|
|
//#link "gfx.c"
|
|
|
|
|
2018-09-05 02:28:12 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2019-06-02 14:53:39 +00:00
|
|
|
#include "bios.h"
|
|
|
|
|
2019-06-01 22:12:34 +00:00
|
|
|
// uncomment to make code better, but slower compile
|
2019-06-02 14:53:39 +00:00
|
|
|
#pragma opt_code_speed
|
2018-09-05 02:28:12 +00:00
|
|
|
|
2018-09-21 12:39:15 +00:00
|
|
|
// start @ $4FCE
|
|
|
|
volatile word MUZPC; // music PC
|
|
|
|
volatile word MUZSP; // music SP
|
|
|
|
volatile byte PVOLAB; // channels A and B volume
|
|
|
|
volatile byte PVOLMC; // channel C volume and noise mask
|
|
|
|
volatile byte VOICES; // voice smask
|
|
|
|
|
|
|
|
volatile byte CT[8]; // counter timers
|
|
|
|
|
2019-06-01 22:12:34 +00:00
|
|
|
// for SENTRY
|
2018-09-21 12:39:15 +00:00
|
|
|
volatile byte CNT;
|
|
|
|
volatile byte SEMI4S;
|
|
|
|
volatile byte OPOT[4];
|
|
|
|
volatile byte KEYSEX;
|
|
|
|
volatile byte OSW[4];
|
|
|
|
volatile word COLLST;
|
|
|
|
|
|
|
|
volatile byte DURAT; // note duration
|
|
|
|
volatile byte TMR60; // 1/60 sec timer
|
|
|
|
volatile byte TIMOUT; // blackout timer
|
|
|
|
volatile byte GTSECS; // seconds timer
|
|
|
|
volatile byte GTMINS; // minutes timer
|
|
|
|
|
|
|
|
unsigned long RANSHT; // RNG
|
|
|
|
byte NUMPLY; // # players
|
|
|
|
byte ENDSCR[3]; // end score
|
|
|
|
byte MRLOCK; // magic register lock out
|
|
|
|
byte GAMSTB; // game status
|
|
|
|
byte PRIOR; // music protect
|
|
|
|
byte SENFLG; // sentry control
|
|
|
|
|
|
|
|
byte* UMARGT; // user mask table (-64 bytes)
|
|
|
|
word* USERTB; // user routine table (-128 bytes)
|
2018-09-05 02:28:12 +00:00
|
|
|
|
2019-06-02 14:53:39 +00:00
|
|
|
// from bmusic.c
|
2019-06-02 02:09:45 +00:00
|
|
|
extern void music_update(void);
|
2019-05-31 19:05:33 +00:00
|
|
|
|
2019-06-03 14:08:29 +00:00
|
|
|
// INTERRUPT HANDLER
|
|
|
|
//#define USE_ALT_REGS
|
|
|
|
void hw_interrupt()
|
|
|
|
#ifdef USE_ALT_REGS
|
|
|
|
__naked {
|
2019-06-01 22:12:34 +00:00
|
|
|
__asm__("ex af,af'");
|
2019-06-03 14:08:29 +00:00
|
|
|
__asm__("exx");
|
|
|
|
#else
|
|
|
|
__interrupt {
|
|
|
|
#endif
|
2018-09-06 20:58:28 +00:00
|
|
|
CT[0]++;
|
|
|
|
CT[1]++;
|
|
|
|
CT[2]++;
|
|
|
|
CT[3]++;
|
|
|
|
if (++TMR60 == 60) {
|
|
|
|
TMR60 = 0;
|
2019-06-01 22:12:34 +00:00
|
|
|
++TIMOUT;
|
2019-06-02 02:09:45 +00:00
|
|
|
KEYSEX |= 0x80; // notify SENTRY
|
2018-09-06 20:58:28 +00:00
|
|
|
if (++GTSECS == 60) {
|
|
|
|
GTMINS++;
|
|
|
|
}
|
|
|
|
}
|
2019-06-02 02:09:45 +00:00
|
|
|
// TODO?
|
|
|
|
if (VOICES) {
|
|
|
|
if (DURAT) {
|
|
|
|
DURAT--;
|
|
|
|
} else {
|
|
|
|
music_update();
|
|
|
|
}
|
|
|
|
}
|
2019-06-03 14:08:29 +00:00
|
|
|
#ifdef USE_ALT_REGS
|
2019-06-01 22:12:34 +00:00
|
|
|
__asm__("exx");
|
|
|
|
__asm__("ex af,af'");
|
2019-06-03 14:08:29 +00:00
|
|
|
__asm__("ei");
|
2019-06-01 22:12:34 +00:00
|
|
|
__asm__("reti");
|
2019-06-03 14:08:29 +00:00
|
|
|
#endif
|
2018-09-06 20:58:28 +00:00
|
|
|
}
|
|
|
|
|
2019-06-02 02:09:45 +00:00
|
|
|
void add_counters(byte mask, byte delta) {
|
2019-05-31 19:05:33 +00:00
|
|
|
byte i = 0;
|
|
|
|
while (mask) {
|
|
|
|
if (mask & 1) {
|
|
|
|
if (CT[i]) {
|
2019-06-02 02:09:45 +00:00
|
|
|
// notify SENTRY if counters go to 0
|
|
|
|
if (!(CT[i] += delta)) {
|
|
|
|
SENFLG |= 1<<i;
|
|
|
|
}
|
2019-05-31 19:05:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
mask >>= 1;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2018-09-05 02:28:12 +00:00
|
|
|
|
|
|
|
void STIMER() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void CTIMER() {
|
|
|
|
}
|
|
|
|
|
2019-05-31 19:05:33 +00:00
|
|
|
void TIMEZ() {
|
|
|
|
// updates game timer, blackout timer, and music processor
|
|
|
|
}
|
|
|
|
|
|
|
|
void TIMEY() {
|
2019-06-02 02:09:45 +00:00
|
|
|
add_counters(0x0f, -1);
|
2019-05-31 19:05:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TIMEX() {
|
|
|
|
}
|
2019-06-03 14:08:29 +00:00
|
|
|
|
|
|
|
void DECCTS(ContextBlock *ctx) {
|
|
|
|
add_counters(_C, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// INTERPRETER
|
2019-05-31 19:05:33 +00:00
|
|
|
|
2018-09-05 02:28:12 +00:00
|
|
|
void INTPC(ContextBlock *ctx) {
|
2019-06-06 19:40:31 +00:00
|
|
|
while (ctx->params[0] > 2) { // 0,2 = exit
|
2018-09-05 02:28:12 +00:00
|
|
|
SYSCALL(ctx);
|
|
|
|
}
|
2019-06-03 14:08:29 +00:00
|
|
|
ctx->params++; // skip EXIT opcode
|
2018-09-05 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// never called, hopefully
|
|
|
|
void EXIT(ContextBlock *ctx) {
|
|
|
|
ctx;
|
|
|
|
}
|
|
|
|
|
|
|
|
// jumps to HL
|
|
|
|
void RCALL(ContextBlock *ctx) {
|
2019-05-30 02:12:11 +00:00
|
|
|
((Routine*)_HL)();
|
2018-09-05 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
2018-09-11 00:44:53 +00:00
|
|
|
// start interpreting at HL
|
|
|
|
void MCALL(ContextBlock *ctx) {
|
2019-06-02 14:53:39 +00:00
|
|
|
ctx->params = (byte*)_HL;
|
|
|
|
while (ctx->params[0] != 8) { // 8 = MRET
|
|
|
|
SYSCALL(ctx);
|
|
|
|
}
|
2018-09-11 00:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// exit MCALL loop
|
|
|
|
void MRET(ContextBlock *ctx) {
|
|
|
|
ctx; // TODO
|
|
|
|
}
|
|
|
|
|
2019-06-03 14:08:29 +00:00
|
|
|
void NOOP(ContextBlock *ctx) {
|
|
|
|
ctx;
|
|
|
|
}
|
|
|
|
|
2018-09-11 00:44:53 +00:00
|
|
|
// jump within MCALL
|
|
|
|
void MJUMP(ContextBlock *ctx) {
|
2019-05-30 02:12:11 +00:00
|
|
|
ctx->params = (byte*) _HL; // TODO?
|
2018-09-11 00:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void suckParams(ContextBlock *ctx, byte argmask) {
|
|
|
|
byte* dest = (byte*) ctx;
|
|
|
|
byte* src = ctx->params;
|
|
|
|
if (argmask & REG_IX) {
|
2019-05-30 02:12:11 +00:00
|
|
|
_IXL = *src++;
|
|
|
|
_IXH = *src++;
|
2018-09-11 00:44:53 +00:00
|
|
|
}
|
|
|
|
if (argmask & REG_E)
|
2019-05-30 02:12:11 +00:00
|
|
|
_E = *src++;
|
2018-09-11 00:44:53 +00:00
|
|
|
if (argmask & REG_D)
|
2019-05-30 02:12:11 +00:00
|
|
|
_D = *src++;
|
2018-09-11 00:44:53 +00:00
|
|
|
if (argmask & REG_C)
|
2019-05-30 02:12:11 +00:00
|
|
|
_C = *src++;
|
2018-09-11 00:44:53 +00:00
|
|
|
if (argmask & REG_B)
|
2019-05-30 02:12:11 +00:00
|
|
|
_B = *src++;
|
2018-09-11 00:44:53 +00:00
|
|
|
if (argmask & REG_A)
|
2019-05-30 02:12:11 +00:00
|
|
|
_A = *src++;
|
2018-09-11 00:44:53 +00:00
|
|
|
if (argmask & REG_HL) {
|
2019-05-30 02:12:11 +00:00
|
|
|
_L = *src++;
|
|
|
|
_H = *src++;
|
2018-09-11 00:44:53 +00:00
|
|
|
}
|
|
|
|
ctx->params = src;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SUCK(ContextBlock* ctx) {
|
2019-05-30 02:12:11 +00:00
|
|
|
suckParams(ctx, _B);
|
2018-09-11 00:44:53 +00:00
|
|
|
}
|
|
|
|
|
2019-05-31 19:05:33 +00:00
|
|
|
|
|
|
|
const void* const actint_vec = &hw_interrupt;
|
|
|
|
|
2018-09-06 20:58:28 +00:00
|
|
|
void ACTINT(ContextBlock *ctx) {
|
|
|
|
ctx;
|
|
|
|
__asm
|
2019-05-31 19:05:33 +00:00
|
|
|
LD BC,#(_actint_vec) ; upper 8 bits of address
|
|
|
|
LD A,B
|
2018-09-06 20:58:28 +00:00
|
|
|
LD I,A
|
|
|
|
IM 2 ; mode 2
|
|
|
|
EI ; enable interrupts
|
|
|
|
__endasm;
|
2019-05-31 19:05:33 +00:00
|
|
|
hw_inlin = 200;
|
|
|
|
hw_infbk = (byte) &actint_vec;
|
|
|
|
hw_inmod = 0x8;
|
|
|
|
TIMEZ();
|
|
|
|
TIMEY();
|
2018-09-06 20:58:28 +00:00
|
|
|
}
|
|
|
|
|
2018-09-05 02:28:12 +00:00
|
|
|
// Outputs D to port 0A, B to port 09, A to port 0E.
|
|
|
|
void SETOUT(ContextBlock *ctx) {
|
2019-05-30 02:12:11 +00:00
|
|
|
hw_verbl = _D;
|
|
|
|
hw_horcb = _B;
|
|
|
|
hw_inmod = _A;
|
2018-09-05 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
2019-06-02 14:53:39 +00:00
|
|
|
// set entire palette at once (8 bytes to port 0xb)
|
|
|
|
// bytes in array should be in reverse
|
2019-06-03 14:08:29 +00:00
|
|
|
void set_palette(byte palette[8]) __z88dk_fastcall;
|
2019-06-02 14:53:39 +00:00
|
|
|
|
2018-09-05 02:28:12 +00:00
|
|
|
// sets color palettes from (HL)
|
|
|
|
void COLSET(ContextBlock *ctx) {
|
2019-06-02 14:53:39 +00:00
|
|
|
set_palette((byte*)_HL);
|
2018-09-05 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stores A in BC bytes starting at location DE.
|
|
|
|
void FILL(ContextBlock *ctx) {
|
2019-05-30 02:12:11 +00:00
|
|
|
byte* dest = (byte*) _DE;
|
|
|
|
word count = _BC;
|
|
|
|
byte val = _A;
|
2018-09-05 02:28:12 +00:00
|
|
|
memset(dest, val, count);
|
|
|
|
}
|
|
|
|
|
2018-09-11 00:44:53 +00:00
|
|
|
void wait_vsync() {
|
|
|
|
byte x = TMR60;
|
|
|
|
while (x == TMR60) ; // wait until timer/60 changes
|
|
|
|
}
|
|
|
|
|
|
|
|
void PAWS(ContextBlock *ctx) {
|
2019-05-30 02:12:11 +00:00
|
|
|
while (_B--) {
|
2018-09-11 00:44:53 +00:00
|
|
|
wait_vsync();
|
|
|
|
}
|
|
|
|
}
|
2018-09-06 20:58:28 +00:00
|
|
|
|
2018-09-21 12:39:15 +00:00
|
|
|
// MATH
|
|
|
|
|
2019-05-30 02:12:11 +00:00
|
|
|
void MOVE(ContextBlock *ctx) {
|
2019-06-03 14:08:29 +00:00
|
|
|
memcpy((byte*)_DE, (const byte*)_HL, _BC);
|
2019-05-30 02:12:11 +00:00
|
|
|
}
|
|
|
|
|
2019-06-03 14:08:29 +00:00
|
|
|
word bcdadd8(byte a, byte b, byte c);
|
2019-05-30 02:12:11 +00:00
|
|
|
|
|
|
|
void BCDADD(ContextBlock *ctx) {
|
|
|
|
byte* dest = (byte*) _DE;
|
|
|
|
const byte* src = (const byte*) _HL;
|
|
|
|
byte n = _B;
|
|
|
|
byte carry = 0;
|
|
|
|
while (n--) {
|
|
|
|
byte a = *src++;
|
|
|
|
byte b = *dest;
|
|
|
|
word r = bcdadd8(a,b,carry);
|
|
|
|
carry = (r>>8);
|
|
|
|
*dest++ = r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-21 12:39:15 +00:00
|
|
|
void RANGED(ContextBlock *ctx) {
|
|
|
|
/* Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs" */
|
|
|
|
RANSHT ^= RANSHT << 13;
|
|
|
|
RANSHT ^= RANSHT >> 17;
|
|
|
|
RANSHT ^= RANSHT << 5;
|
2019-05-30 02:12:11 +00:00
|
|
|
if (_A == 0) {
|
|
|
|
_A = (byte)RANSHT;
|
2018-09-21 12:39:15 +00:00
|
|
|
} else {
|
2019-05-30 02:12:11 +00:00
|
|
|
_A = (byte)(RANSHT % _A);
|
2018-09-21 12:39:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 19:40:31 +00:00
|
|
|
void INDEXB(ContextBlock *ctx) {
|
|
|
|
word addr = _HL + _A;
|
|
|
|
_HL = addr;
|
|
|
|
_A = *((byte*)addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void INDEXW(ContextBlock *ctx) {
|
|
|
|
word addr = _HL + _A*2;
|
|
|
|
_HL = addr;
|
|
|
|
_DE = *((word*)addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void INDEXN(ContextBlock *ctx) {
|
|
|
|
byte ofs = _C;
|
|
|
|
word addr = _HL + ofs/2;
|
|
|
|
byte val = *((byte*)addr);
|
|
|
|
_A = (ofs & 1) ? (val>>4) : (val&0xf);
|
|
|
|
}
|
|
|
|
|
2019-06-01 22:12:34 +00:00
|
|
|
// input
|
|
|
|
|
2019-06-03 14:08:29 +00:00
|
|
|
extern const byte KCTASC_TABLE[25];
|
2019-06-02 14:53:39 +00:00
|
|
|
|
|
|
|
void KCTASC(ContextBlock *ctx) {
|
|
|
|
_A = KCTASC_TABLE[_B];
|
2019-06-01 22:12:34 +00:00
|
|
|
}
|
|
|
|
|
2019-06-02 14:53:39 +00:00
|
|
|
// music
|
|
|
|
|
2019-06-02 02:09:45 +00:00
|
|
|
void BMUSIC(ContextBlock *ctx) {
|
|
|
|
VOICES = _A;
|
|
|
|
MUZPC = _HL;
|
|
|
|
MUZSP = _IX;
|
|
|
|
DURAT = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EMUSIC(ContextBlock *ctx) {
|
|
|
|
ctx;
|
|
|
|
VOICES = 0;
|
|
|
|
}
|
|
|
|
|
2019-06-02 14:53:39 +00:00
|
|
|
// externals
|
|
|
|
|
|
|
|
extern void SENTRY(ContextBlock *ctx);
|
|
|
|
extern void DOIT(ContextBlock *ctx);
|
|
|
|
extern void DOITB(ContextBlock *ctx);
|
|
|
|
|
|
|
|
extern void RECTAN(const ContextBlock *ctx);
|
|
|
|
extern void WRITR(const ContextBlock *ctx);
|
|
|
|
extern void WRITP(const ContextBlock *ctx);
|
|
|
|
extern void WRIT(const ContextBlock *ctx);
|
|
|
|
extern void CHRDIS(const ContextBlock *ctx);
|
|
|
|
extern void STRDIS(const ContextBlock *ctx);
|
|
|
|
extern void DISNUM(const ContextBlock *ctx);
|
|
|
|
|
|
|
|
// table
|
|
|
|
|
2018-09-05 02:28:12 +00:00
|
|
|
const SysCallEntry SYSCALL_TABLE[64] = {
|
|
|
|
/* 0 */
|
|
|
|
{ &INTPC, 0 },
|
|
|
|
{ &EXIT, 0 },
|
|
|
|
{ &RCALL, REG_HL },
|
2018-09-11 00:44:53 +00:00
|
|
|
{ &MCALL, REG_HL },
|
|
|
|
{ &MRET, 0 },
|
2018-09-05 02:28:12 +00:00
|
|
|
/* 10 */
|
2018-09-11 00:44:53 +00:00
|
|
|
{ &MJUMP, REG_HL },
|
|
|
|
{ &SUCK, REG_B },
|
2018-09-06 20:58:28 +00:00
|
|
|
{ &ACTINT, 0 },
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &DECCTS, REG_C },
|
2019-06-02 02:09:45 +00:00
|
|
|
{ &BMUSIC, REG_HL|REG_IX|REG_A },
|
2018-09-05 02:28:12 +00:00
|
|
|
/* 20 */
|
2019-06-02 02:09:45 +00:00
|
|
|
{ &EMUSIC, },
|
2018-09-05 02:28:12 +00:00
|
|
|
{ &SETOUT, REG_D|REG_B|REG_A },
|
|
|
|
{ &COLSET, REG_HL },
|
|
|
|
{ &FILL, REG_A|REG_BC|REG_DE },
|
2019-05-30 02:12:11 +00:00
|
|
|
{ &RECTAN, REG_A|REG_B|REG_C|REG_D|REG_E },
|
2018-09-05 02:28:12 +00:00
|
|
|
/* 30 */
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &NOOP, REG_HL|REG_IX }, // VWRITR
|
2019-06-01 22:12:34 +00:00
|
|
|
{ &WRITR, REG_E|REG_D|REG_A|REG_HL },
|
|
|
|
{ &WRITP, REG_E|REG_D|REG_A|REG_HL },
|
|
|
|
{ &WRIT, REG_E|REG_D|REG_C|REG_B|REG_A|REG_HL },
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &NOOP, REG_E|REG_D|REG_C|REG_B|REG_A|REG_HL }, // WRITA
|
2018-09-05 02:28:12 +00:00
|
|
|
/* 40 */
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &NOOP, REG_E|REG_D|REG_IX }, // VBLANK
|
|
|
|
{ &NOOP, REG_E|REG_D|REG_B|REG_HL }, // BLANK
|
|
|
|
{ &NOOP, REG_B|REG_C|REG_DE|REG_HL }, // SAVE
|
|
|
|
{ &NOOP, REG_DE|REG_HL }, // RESTORE
|
|
|
|
{ &NOOP, REG_B|REG_C|REG_DE|REG_HL }, // SCROLL
|
2018-09-05 02:28:12 +00:00
|
|
|
/* 50 */
|
|
|
|
{ &CHRDIS, REG_E|REG_D|REG_C|REG_A },
|
|
|
|
{ &STRDIS, REG_E|REG_D|REG_C|REG_HL },
|
2019-05-30 02:12:11 +00:00
|
|
|
{ &DISNUM, REG_E|REG_D|REG_C|REG_B|REG_HL },
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &NOOP, REG_DE|REG_A }, // RELABS
|
|
|
|
{ &NOOP, REG_E|REG_D|REG_A }, // RELAB1
|
2018-09-05 02:28:12 +00:00
|
|
|
/* 60 */
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &NOOP, REG_IX|REG_HL|REG_C }, // VECTC
|
|
|
|
{ &NOOP, REG_IX|REG_HL }, // VECT
|
2019-06-02 14:53:39 +00:00
|
|
|
{ &KCTASC, 0 },
|
2019-06-01 22:12:34 +00:00
|
|
|
{ &SENTRY, REG_DE },
|
2019-06-02 14:53:39 +00:00
|
|
|
{ &DOIT, REG_HL },
|
2018-09-05 02:28:12 +00:00
|
|
|
/* 70 */
|
2019-06-02 14:53:39 +00:00
|
|
|
{ &DOITB, REG_HL },
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &NOOP, 0 }, // PIZBRK
|
|
|
|
{ &NOOP, REG_DE|REG_HL }, // MENU
|
|
|
|
{ &NOOP, REG_BC|REG_HL }, // GETPAR
|
|
|
|
{ &NOOP, REG_B|REG_C|REG_D|REG_E|REG_HL }, // GETNUM
|
2018-09-05 02:28:12 +00:00
|
|
|
/* 80 */
|
2018-09-11 00:44:53 +00:00
|
|
|
{ &PAWS, REG_B },
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &NOOP, REG_E|REG_D|REG_C }, // DISTIM
|
|
|
|
{ &NOOP, REG_HL }, // INCSCR
|
2019-06-06 19:40:31 +00:00
|
|
|
{ &INDEXN, REG_C|REG_HL }, // INDEXN
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &NOOP, REG_HL }, // STOREN
|
2018-09-05 02:28:12 +00:00
|
|
|
/* 90 */
|
2019-06-06 19:40:31 +00:00
|
|
|
{ &INDEXW, REG_A|REG_HL }, // INDEXW
|
|
|
|
{ &INDEXB, REG_A|REG_HL }, // INDEXB
|
2019-05-30 02:12:11 +00:00
|
|
|
{ &MOVE, REG_DE|REG_BC|REG_HL },
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &NOOP, 0 }, // SHIFTU
|
2019-05-30 02:12:11 +00:00
|
|
|
{ &BCDADD, REG_DE|REG_B|REG_HL },
|
2018-09-05 02:28:12 +00:00
|
|
|
/* 100 */
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &NOOP, 0 }, // BCDSUB
|
|
|
|
{ &NOOP, 0 }, // BCDMUL
|
|
|
|
{ &NOOP, 0 }, // BCDDIV
|
|
|
|
{ &NOOP, 0 }, // BCDCHS
|
|
|
|
{ &NOOP, 0 }, // BCDNEG
|
2018-09-05 02:28:12 +00:00
|
|
|
/* 110 */
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &NOOP, 0 }, // DADD
|
|
|
|
{ &NOOP, 0 }, // DSMG
|
|
|
|
{ &NOOP, 0 }, // DABS
|
|
|
|
{ &NOOP, 0 }, // NEGT
|
2018-09-21 12:39:15 +00:00
|
|
|
{ &RANGED, REG_A },
|
2018-09-05 02:28:12 +00:00
|
|
|
/* 120 */
|
2019-06-03 14:08:29 +00:00
|
|
|
{ &NOOP, 0 }, // QUIT
|
|
|
|
{ &NOOP, REG_A|REG_HL }, // SETB
|
|
|
|
{ &NOOP, REG_DE|REG_HL }, // SETW
|
|
|
|
{ &NOOP, REG_C|REG_DE|REG_HL }, // MSKTD
|
2018-09-05 02:28:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void SYSCALL(ContextBlock *ctx) {
|
|
|
|
byte op = *ctx->params++;
|
|
|
|
byte argmask;
|
|
|
|
SysRoutine* routine;
|
|
|
|
// user-defined?
|
|
|
|
if (op & 0x80) {
|
2018-09-21 12:39:15 +00:00
|
|
|
argmask = UMARGT[op>>1];
|
|
|
|
routine = (SysRoutine*) USERTB[op>>1];
|
2018-09-05 02:28:12 +00:00
|
|
|
} else {
|
|
|
|
const SysCallEntry* entry = &SYSCALL_TABLE[op>>1];
|
|
|
|
argmask = entry->argmask;
|
|
|
|
routine = entry->routine;
|
|
|
|
}
|
|
|
|
// suck params into context block?
|
|
|
|
if (op & 1) {
|
|
|
|
suckParams(ctx, argmask);
|
|
|
|
}
|
|
|
|
// call the routine
|
2019-06-03 14:08:29 +00:00
|
|
|
routine(ctx);
|
2018-09-05 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
2019-05-30 02:12:11 +00:00
|
|
|
void bios_init() {
|
2019-06-03 14:08:29 +00:00
|
|
|
ContextBlock ctx;
|
2019-05-30 02:12:11 +00:00
|
|
|
memset((void*)0x4fce, 0, 0x5000-0x4fce);
|
|
|
|
ACTINT(0);
|
|
|
|
hw_verbl = 96*2;
|
|
|
|
hw_horcb = 41;
|
|
|
|
hw_inmod = 0x8;
|
2019-06-02 02:09:45 +00:00
|
|
|
// call SENTRY once to set current values
|
|
|
|
// (context block doesn't matter)
|
2019-06-03 14:08:29 +00:00
|
|
|
SENTRY(&ctx);
|
2019-05-30 02:12:11 +00:00
|
|
|
}
|