1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-25 18:33:11 +00:00

bios fixes

This commit is contained in:
Steven Hugg 2018-09-06 16:58:28 -04:00
parent 3b4f933d20
commit 8e3dae776b
2 changed files with 166 additions and 65 deletions

View File

@ -20,14 +20,15 @@ __sfr __at(0x05) hw_col1l;
__sfr __at(0x06) hw_col2l;
__sfr __at(0x07) hw_col3l; // palette 7
__sfr __at(0x08) hw_intst; // intercept test feedback
__sfr __at(0x09) hw_horcb; // horiz color boundary
__sfr __at(0x0a) hw_verbl; // vertical blanking line * 2
__sfr __at(0x0c) hw_magic; // magic register
__sfr __at(0x0d) hw_infbk; // interrupt feedback
__sfr __at(0x0e) hw_inmod; // interrupt enable
__sfr __at(0x0f) hw_inlin; // interrupt line
__sfr __at(0x19) hw_xpand; // expander register
__sfr __at(0x08) hw_intst; // intercept test feedback
__sfr __at(0x10) hw_p1ctrl; // player controls
__sfr __at(0x11) hw_p2ctrl; // player controls
__sfr __at(0x12) hw_p3ctrl; // player controls
@ -70,7 +71,7 @@ byte SEMI4S; // $4FDE // SEMAPHORE flag bitS
byte OPOT[4]; // $4FDF // Old POT 0 tracking byte
byte KEYSEX; // $4FE3 // KEYS-EX tracking byte
byte OSW[4]; // $4FE4 // Old SWitch 0 tracking byte
byte COLLST; // $4FE8 // COLset LaST address for P.B. A
word COLLST; // $4FE8 // COLset LaST address for P.B. A
// Used by STIMER:
byte DURAT; // $4FEA // note DURATion
byte TMR60; // $4FEB // TiMeR for SIXTY'ths of sec
@ -92,61 +93,96 @@ word* USERTB; // $4FFD // USER Table Base + routine = JumP address
// start routine @ 0x0
void bios_start() __naked {
__asm
DI
LD SP,#0x4fce
CALL _bios_init
LD HL,#0x2005
LD A,(HL)
INC HL
DI
LD SP,#0x4fce
CALL _bios_init
LD HL,#0x2005
LD A,(HL)
INC HL
#ifndef TEST
LD H,(HL)
LD L,A
JP (HL)
LD H,(HL)
LD L,A
JP (HL)
#else
jp _main
JP _main
#endif
.ds 0x38 - 0xf ; skip to 0x38
.ds 0x38 - 0xf ; skip to 0x38
__endasm;
}
void interrupt_0x38() __naked {
__asm
push hl
push af
push bc
push de
push ix
push iy
ld hl,#0
add hl,sp
push hl
call _SYSCALL
pop hl
pop iy
pop ix
pop de
pop bc
pop af
pop hl
ret
push hl
push af
push bc
push de
push ix
push iy
ld hl,#0
add hl,sp
push hl
call _SYSCALL
pop hl
pop iy
pop ix
pop de
pop bc
pop af
pop hl
ret
__endasm;
}
void _predope() __naked {
__asm
.ds 0x200-0x52 ; skip to 0x200
.ds 0x200-0x52 ; skip to 0x200
__endasm;
}
// DOPE vector @ 0x200
void DOPE() __naked {
__asm
JP _STIMER
JP _CTIMER
JP _STIMER
JP _CTIMER
.db 0x20, 8, 8, 1, 7
.dw _BIGFONT
.db 0xa0, 4, 6, 1, 5
.dw _SMLFONT
__endasm;
}
// TODO: font defs
typedef struct {
byte base_ch;
byte frame_x;
byte frame_y;
byte pattern_x;
byte pattern_y;
const byte* chartab;
} FontDescriptor;
#define LOCHAR 32
#define HICHAR 127
extern const char BIGFONT[HICHAR-LOCHAR+1][7];
extern const char SMLFONT[HICHAR-LOCHAR+1][5];
const FontDescriptor __at(0x206) FNTSYS; // = { 0x20, 8, 8, 1, 7, (byte*)BIGFONT };
const FontDescriptor __at(0x20d) FNTSML; // = { 0xa0, 4, 6, 1, 5, (byte*)SMLFONT };
void hw_interrupt() __interrupt {
CT[0]++;
CT[1]++;
CT[2]++;
CT[3]++;
if (++TMR60 == 60) {
TMR60 = 0;
if (++GTSECS == 60) {
GTMINS++;
}
}
}
const void* const actint_vec = &hw_interrupt;
void STIMER() {
}
@ -209,6 +245,19 @@ void RCALL(ContextBlock *ctx) {
((Routine*)ctx->regs.w.hl)();
}
void ACTINT(ContextBlock *ctx) {
ctx;
hw_inlin = 200;
hw_infbk = (byte) &actint_vec;
hw_inmod = 8;
__asm
LD A,#0x2 ; I = 0x200
LD I,A
IM 2 ; mode 2
EI ; enable interrupts
__endasm;
}
// Outputs D to port 0A, B to port 09, A to port 0E.
void SETOUT(ContextBlock *ctx) {
hw_verbl = ctx->regs.b.d;
@ -237,20 +286,19 @@ void FILL(ContextBlock *ctx) {
memset(dest, val, count);
}
#define LOCHAR 32
#define HICHAR 127
#define FONT_BWIDTH 1
#define FONT_HEIGHT 8
const char FONT[HICHAR-LOCHAR+1][FONT_HEIGHT*FONT_BWIDTH] = {
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, },{ 0x00,0x00,0x00,0x20,0x20,0x20,0x00,0x20, },{ 0x00,0x00,0x50,0x50,0x50,0x00,0x00,0x00, },{ 0x00,0x00,0x00,0x50,0xF8,0x50,0xF8,0x50, },{ 0x00,0x00,0x00,0xF8,0xA0,0xF8,0x28,0xF8, },{ 0x00,0x00,0x00,0xC8,0xD0,0x20,0x58,0x98, },{ 0x00,0x00,0x00,0xE0,0xA8,0xF8,0x90,0xF8, },{ 0x00,0x00,0x40,0x40,0x40,0x00,0x00,0x00, },{ 0x00,0x00,0x30,0x20,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x60,0x20,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x00,0x20,0xA8,0x70,0xA8,0x20, },{ 0x00,0x00,0x00,0x20,0x20,0xF8,0x20,0x20, },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60, },{ 0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00, },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60, },{ 0x00,0x00,0x00,0x08,0x10,0x20,0x40,0x80, },{ 0x00,0x00,0x00,0xF8,0x88,0xE8,0x88,0xF8, },{ 0x00,0x00,0x00,0x10,0x30,0x50,0x10,0x10, },{ 0x00,0x00,0x00,0xF8,0x08,0xF8,0x80,0xF8, },{ 0x00,0x00,0x00,0xF8,0x08,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0x38,0x48,0x88,0xF8,0x08, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x08,0x10,0x20,0x40, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30, },{ 0x00,0x00,0x00,0x30,0x30,0x00,0x30,0x30, },{ 0x00,0x00,0x08,0x10,0x20,0x40,0x20,0x10, },{ 0x00,0x00,0x00,0x00,0xF8,0x00,0xF8,0x00, },{ 0x00,0x00,0x40,0x20,0x10,0x08,0x10,0x20, },{ 0x00,0x00,0x00,0xF8,0x08,0x78,0x00,0x60, },{ 0x00,0x00,0x00,0xF8,0xA8,0xB8,0x80,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x88,0x88, },{ 0x00,0x00,0x00,0xF0,0x90,0xF8,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0x80,0x80,0xF8, },{ 0x00,0x00,0x00,0xE0,0x90,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x80,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x80,0x80, },{ 0x00,0x00,0x00,0xF8,0x80,0xB8,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x88,0xF8,0x88,0x88, },{ 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40, },{ 0x00,0x00,0x00,0x08,0x08,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x90,0xA0,0x90,0x88, },{ 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xF8, },{ 0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0x92, },{ 0x00,0x00,0x00,0x88,0xC8,0xA8,0x98,0x88, },{ 0x00,0x00,0x00,0xF8,0x88,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0x88,0xF8,0x80, },{ 0x00,0x00,0x00,0xF8,0x88,0xA8,0xA8,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x90,0x88, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x00,0x88,0x88,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x88,0x90,0xA0,0xC0, },{ 0x00,0x00,0x00,0x92,0x92,0x92,0x92,0xFE, },{ 0x00,0x00,0x00,0x88,0x50,0x20,0x50,0x88, },{ 0x00,0x00,0x00,0x88,0x88,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x10,0x20,0x40,0xF8, },{ 0x00,0x00,0x38,0x20,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x08, },{ 0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10, },{ 0x00,0x00,0x00,0x20,0x50,0x88,0x00,0x00, },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, },{ 0x00,0x00,0x40,0x20,0x10,0x00,0x00,0x00, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x88,0x88, },{ 0x00,0x00,0x00,0xF0,0x90,0xF8,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0x80,0x80,0xF8, },{ 0x00,0x00,0x00,0xE0,0x90,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x80,0xF8, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x80,0x80, },{ 0x00,0x00,0x00,0xF8,0x80,0xB8,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x88,0xF8,0x88,0x88, },{ 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40, },{ 0x00,0x00,0x00,0x08,0x08,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x90,0xA0,0x90,0x88, },{ 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xF8, },{ 0x00,0x00,0x00,0xFE,0x92,0x92,0x92,0x92, },{ 0x00,0x00,0x00,0x88,0xC8,0xA8,0x98,0x88, },{ 0x00,0x00,0x00,0xF8,0x88,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0x88,0xF8,0x80, },{ 0x00,0x00,0x00,0xF8,0x88,0xA8,0xA8,0xF8, },{ 0x00,0x00,0x00,0xF8,0x88,0xF8,0x90,0x88, },{ 0x00,0x00,0x00,0xF8,0x80,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0x00,0x88,0x88,0x88,0x88,0xF8, },{ 0x00,0x00,0x00,0x88,0x88,0x90,0xA0,0xC0, },{ 0x00,0x00,0x00,0x92,0x92,0x92,0x92,0xFE, },{ 0x00,0x00,0x00,0x88,0x50,0x20,0x50,0x88, },{ 0x00,0x00,0x00,0x88,0x88,0xF8,0x08,0xF8, },{ 0x00,0x00,0x00,0xF8,0x10,0x20,0x40,0xF8, },{ 0x00,0x00,0x38,0x20,0x20,0xE0,0x20,0x20, },{ 0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20, },{ 0x00,0x00,0xE0,0x20,0x20,0x38,0x20,0x20, },{ 0x00,0x00,0x00,0xE8,0xB8,0x00,0x00,0x00, },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, },};
const char BIGFONT[HICHAR-LOCHAR+1][7] = {
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00 },{ 0x00,0x20,0x20,0x20,0x00,0x20,0x00 },{ 0x50,0x50,0x50,0x00,0x00,0x00,0x00 },{ 0x00,0x50,0xF8,0x50,0xF8,0x50,0x00 },{ 0x00,0xF8,0xA0,0xF8,0x28,0xF8,0x00 },{ 0x00,0xC8,0xD0,0x20,0x58,0x98,0x00 },{ 0x00,0xE0,0xA8,0xF8,0x90,0xF8,0x00 },{ 0x40,0x40,0x40,0x00,0x00,0x00,0x00 },{ 0x30,0x20,0x20,0x20,0x20,0x20,0x30 },{ 0x60,0x20,0x20,0x20,0x20,0x20,0x60 },{ 0x00,0x20,0xA8,0x70,0xA8,0x20,0x00 },{ 0x00,0x20,0x20,0xF8,0x20,0x20,0x00 },{ 0x00,0x00,0x00,0x00,0x60,0x60,0x40 },{ 0x00,0x00,0x00,0xF8,0x00,0x00,0x00 },{ 0x00,0x00,0x00,0x00,0x60,0x60,0x00 },{ 0x00,0x08,0x10,0x20,0x40,0x80,0x00 },{ 0x00,0xF8,0x88,0xE8,0x88,0xF8,0x00 },{ 0x00,0x10,0x30,0x50,0x10,0x10,0x00 },{ 0x00,0xF8,0x08,0xF8,0x80,0xF8,0x00 },{ 0x00,0xF8,0x08,0xF8,0x08,0xF8,0x00 },{ 0x00,0x38,0x48,0x88,0xF8,0x08,0x00 },{ 0x00,0xF8,0x80,0xF8,0x08,0xF8,0x00 },{ 0x00,0xF8,0x80,0xF8,0x88,0xF8,0x00 },{ 0x00,0xF8,0x08,0x10,0x20,0x40,0x00 },{ 0x00,0xF8,0x88,0xF8,0x88,0xF8,0x00 },{ 0x00,0xF8,0x88,0xF8,0x08,0xF8,0x00 },{ 0x00,0x30,0x30,0x00,0x30,0x30,0x00 },{ 0x00,0x30,0x30,0x00,0x30,0x30,0x20 },{ 0x08,0x10,0x20,0x40,0x20,0x10,0x08 },{ 0x00,0x00,0xF8,0x00,0xF8,0x00,0x00 },{ 0x40,0x20,0x10,0x08,0x10,0x20,0x40 },{ 0x00,0xF8,0x08,0x78,0x00,0x60,0x00 },{ 0x00,0xF8,0xA8,0xB8,0x80,0xF8,0x00 },{ 0x00,0xF8,0x88,0xF8,0x88,0x88,0x00 },{ 0x00,0xF0,0x90,0xF8,0x88,0xF8,0x00 },{ 0x00,0xF8,0x80,0x80,0x80,0xF8,0x00 },{ 0x00,0xE0,0x90,0x88,0x88,0xF8,0x00 },{ 0x00,0xF8,0x80,0xF8,0x80,0xF8,0x00 },{ 0x00,0xF8,0x80,0xF8,0x80,0x80,0x00 },{ 0x00,0xF8,0x80,0xB8,0x88,0xF8,0x00 },{ 0x00,0x88,0x88,0xF8,0x88,0x88,0x00 },{ 0x00,0x40,0x40,0x40,0x40,0x40,0x00 },{ 0x00,0x08,0x08,0x88,0x88,0xF8,0x00 },{ 0x00,0x88,0x90,0xA0,0x90,0x88,0x00 },{ 0x00,0x80,0x80,0x80,0x80,0xF8,0x00 },{ 0x00,0xFE,0x92,0x92,0x92,0x92,0x00 },{ 0x00,0x88,0xC8,0xA8,0x98,0x88,0x00 },{ 0x00,0xF8,0x88,0x88,0x88,0xF8,0x00 },{ 0x00,0xF8,0x88,0x88,0xF8,0x80,0x00 },{ 0x00,0xF8,0x88,0xA8,0xA8,0xF8,0x10 },{ 0x00,0xF8,0x88,0xF8,0x90,0x88,0x00 },{ 0x00,0xF8,0x80,0xF8,0x08,0xF8,0x00 },{ 0x00,0xF8,0x20,0x20,0x20,0x20,0x00 },{ 0x00,0x88,0x88,0x88,0x88,0xF8,0x00 },{ 0x00,0x88,0x88,0x90,0xA0,0xC0,0x00 },{ 0x00,0x92,0x92,0x92,0x92,0xFE,0x00 },{ 0x00,0x88,0x50,0x20,0x50,0x88,0x00 },{ 0x00,0x88,0x88,0xF8,0x08,0xF8,0x00 },{ 0x00,0xF8,0x10,0x20,0x40,0xF8,0x00 },{ 0x38,0x20,0x20,0x20,0x20,0x20,0x38 },{ 0x00,0x80,0x40,0x20,0x10,0x08,0x00 },{ 0x70,0x10,0x10,0x10,0x10,0x10,0x70 },{ 0x00,0x20,0x50,0x88,0x00,0x00,0x00 },{ 0x00,0x00,0x00,0x00,0x00,0x00,0xF8 },{ 0x40,0x20,0x10,0x00,0x00,0x00,0x00 },{ 0x00,0xF8,0x88,0xF8,0x88,0x88,0x00 },{ 0x00,0xF0,0x90,0xF8,0x88,0xF8,0x00 },{ 0x00,0xF8,0x80,0x80,0x80,0xF8,0x00 },{ 0x00,0xE0,0x90,0x88,0x88,0xF8,0x00 },{ 0x00,0xF8,0x80,0xF8,0x80,0xF8,0x00 },{ 0x00,0xF8,0x80,0xF8,0x80,0x80,0x00 },{ 0x00,0xF8,0x80,0xB8,0x88,0xF8,0x00 },{ 0x00,0x88,0x88,0xF8,0x88,0x88,0x00 },{ 0x00,0x40,0x40,0x40,0x40,0x40,0x00 },{ 0x00,0x08,0x08,0x88,0x88,0xF8,0x00 },{ 0x00,0x88,0x90,0xA0,0x90,0x88,0x00 },{ 0x00,0x80,0x80,0x80,0x80,0xF8,0x00 },{ 0x00,0xFE,0x92,0x92,0x92,0x92,0x00 },{ 0x00,0x88,0xC8,0xA8,0x98,0x88,0x00 },{ 0x00,0xF8,0x88,0x88,0x88,0xF8,0x00 },{ 0x00,0xF8,0x88,0x88,0xF8,0x80,0x00 },{ 0x00,0xF8,0x88,0xA8,0xA8,0xF8,0x10 },{ 0x00,0xF8,0x88,0xF8,0x90,0x88,0x00 },{ 0x00,0xF8,0x80,0xF8,0x08,0xF8,0x00 },{ 0x00,0xF8,0x20,0x20,0x20,0x20,0x00 },{ 0x00,0x88,0x88,0x88,0x88,0xF8,0x00 },{ 0x00,0x88,0x88,0x90,0xA0,0xC0,0x00 },{ 0x00,0x92,0x92,0x92,0x92,0xFE,0x00 },{ 0x00,0x88,0x50,0x20,0x50,0x88,0x00 },{ 0x00,0x88,0x88,0xF8,0x08,0xF8,0x00 },{ 0x00,0xF8,0x10,0x20,0x40,0xF8,0x00 },{ 0x38,0x20,0x20,0xE0,0x20,0x20,0x38 },{ 0x20,0x20,0x20,0x20,0x20,0x20,0x20 },{ 0xE0,0x20,0x20,0x38,0x20,0x20,0xE0 },{ 0x00,0xE8,0xB8,0x00,0x00,0x00,0x00 },{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00 },};
const char SMLFONT[HICHAR-LOCHAR+1][5] = {
{ 0x00,0x00,0x00,0x00,0x00 },{ 0x40,0x40,0x00,0x40,0x00 },{ 0xA0,0xA0,0x00,0x00,0x00 },{ 0x60,0xF0,0xF0,0x60,0x00 },{ 0x40,0xE0,0xE0,0x40,0x00 },{ 0x90,0x20,0x40,0x90,0x00 },{ 0xC0,0xB0,0xE0,0xD0,0x00 },{ 0x20,0x40,0x00,0x00,0x00 },{ 0x20,0x40,0x40,0x20,0x00 },{ 0x40,0x20,0x20,0x40,0x00 },{ 0x40,0xE0,0x40,0xA0,0x00 },{ 0x00,0x40,0xE0,0x40,0x00 },{ 0x00,0x00,0x00,0x60,0x20 },{ 0x00,0x00,0xE0,0x00,0x00 },{ 0x00,0x00,0x00,0x40,0x00 },{ 0x20,0x20,0x40,0x40,0x00 },{ 0xE0,0xA0,0xA0,0xE0,0x00 },{ 0xC0,0x40,0x40,0xE0,0x00 },{ 0xE0,0x20,0xC0,0xE0,0x00 },{ 0xE0,0x60,0x20,0xE0,0x00 },{ 0xA0,0xA0,0xE0,0x20,0x00 },{ 0xE0,0xC0,0x20,0xE0,0x00 },{ 0xC0,0x80,0xE0,0xE0,0x00 },{ 0xE0,0x20,0x40,0x40,0x00 },{ 0x60,0xE0,0xA0,0xE0,0x00 },{ 0xE0,0xE0,0x20,0x60,0x00 },{ 0x00,0x40,0x00,0x40,0x00 },{ 0x00,0x40,0x00,0x60,0x20 },{ 0x00,0x20,0x40,0x20,0x00 },{ 0x00,0xE0,0x00,0xE0,0x00 },{ 0x00,0x40,0x20,0x40,0x00 },{ 0xE0,0x20,0x60,0x00,0x40 },{ 0xF0,0x90,0x10,0xD0,0xF0 },{ 0x60,0xA0,0xE0,0xA0,0x00 },{ 0xC0,0xE0,0xA0,0xE0,0x00 },{ 0x60,0x80,0x80,0xE0,0x00 },{ 0xC0,0xA0,0xA0,0xC0,0x00 },{ 0xE0,0xC0,0x80,0xE0,0x00 },{ 0xE0,0xC0,0x80,0x80,0x00 },{ 0x60,0x80,0xA0,0xE0,0x00 },{ 0xA0,0xA0,0xE0,0xA0,0x00 },{ 0xE0,0x40,0x40,0xE0,0x00 },{ 0x60,0x20,0xA0,0xE0,0x00 },{ 0xA0,0xC0,0xC0,0xA0,0x00 },{ 0x80,0x80,0x80,0xE0,0x00 },{ 0xE0,0xE0,0xE0,0xA0,0x00 },{ 0xE0,0xA0,0xA0,0xA0,0x00 },{ 0xE0,0xA0,0xA0,0xE0,0x00 },{ 0xE0,0xA0,0xE0,0x80,0x00 },{ 0xE0,0xA0,0xE0,0xF0,0x00 },{ 0xE0,0xA0,0xC0,0xA0,0x00 },{ 0xE0,0x80,0x60,0xE0,0x00 },{ 0xE0,0x40,0x40,0x40,0x00 },{ 0xA0,0xA0,0xA0,0xE0,0x00 },{ 0xA0,0xA0,0xC0,0x80,0x00 },{ 0xA0,0xE0,0xE0,0xE0,0x00 },{ 0xA0,0x40,0xA0,0xA0,0x00 },{ 0xA0,0xE0,0x40,0x40,0x00 },{ 0xE0,0x20,0x40,0xE0,0x00 },{ 0x60,0x40,0x40,0x60,0x00 },{ 0x40,0x40,0x20,0x20,0x00 },{ 0x60,0x20,0x20,0x60,0x00 },{ 0x40,0xA0,0x00,0x00,0x00 },{ 0x00,0x00,0x00,0x00,0xF0 },{ 0x80,0x40,0x00,0x00,0x00 },{ 0x00,0x60,0xA0,0xE0,0x00 },{ 0x80,0xE0,0xA0,0xE0,0x00 },{ 0x00,0x60,0x80,0xE0,0x00 },{ 0x20,0xE0,0xA0,0xE0,0x00 },{ 0x00,0xE0,0xA0,0xC0,0x00 },{ 0x20,0x40,0x60,0x40,0x00 },{ 0x00,0x60,0xA0,0x60,0xC0 },{ 0x80,0xE0,0xA0,0xA0,0x00 },{ 0x40,0x00,0x40,0x40,0x00 },{ 0x40,0x00,0x40,0x40,0xC0 },{ 0x80,0xA0,0xC0,0xA0,0x00 },{ 0xC0,0x40,0x40,0x60,0x00 },{ 0x00,0xE0,0xE0,0xA0,0x00 },{ 0x00,0xE0,0xA0,0xA0,0x00 },{ 0x00,0xE0,0xA0,0xE0,0x00 },{ 0x00,0xE0,0xA0,0xE0,0x80 },{ 0x00,0xE0,0xA0,0xE0,0x20 },{ 0x00,0xE0,0x80,0x80,0x00 },{ 0x00,0x60,0x40,0xC0,0x00 },{ 0x40,0x60,0x40,0x60,0x00 },{ 0x00,0xA0,0xA0,0xE0,0x00 },{ 0x00,0xA0,0xE0,0x40,0x00 },{ 0x00,0xA0,0xE0,0xE0,0x00 },{ 0x00,0xA0,0x40,0xA0,0x00 },{ 0x00,0xA0,0xE0,0x20,0xC0 },{ 0x00,0xC0,0x40,0x60,0x00 },{ 0x60,0xC0,0x40,0x60,0x00 },{ 0x40,0x40,0x40,0x40,0x40 },{ 0xC0,0x60,0x40,0xC0,0x00 },{ 0x20,0xE0,0x80,0x00,0x00 },};
// draw a letter
void draw_char(byte ch, byte x, byte y, byte op) {
const byte* src = &FONT[(ch-LOCHAR)][0];
void draw_char(const FontDescriptor* font, byte ch, byte x, byte y, byte op) {
const byte* src = font->chartab + (ch-font->base_ch)*font->pattern_y;
byte xb = x>>2; // divide x by 4
byte* dest = &vmagic[y][xb]; // destination address
hw_magic = M_SHIFT(x) | M_XPAND | op;
for (byte i=0; i<8; i++) {
for (byte i=0; i<font->pattern_y; i++) {
char b = *src++;
EXIT_CLIPDEST(dest);
*dest++ = b; // expand lower nibble -> 1st byte
@ -261,12 +309,38 @@ void draw_char(byte ch, byte x, byte y, byte op) {
}
}
void draw_string(const char* str, byte x, byte y, byte op) {
#define FONT_IX ((const FontDescriptor*)ctx->regs.w.ix)
void draw_string(ContextBlock *ctx, const char* str, byte x, byte y, byte op) {
do {
byte ch = *str++;
if (!ch) break;
draw_char(ch, x, y, op);
x += 8;
if (!ch) {
ctx->regs.b.e = x;
break;
}
if (ch < 0x20) {
x += 8 * ch;
} else if (ch < 0x64) {
draw_char(&FNTSYS, ch, x, y, op);
x += 8;
} else if (ch >= 0x80) {
draw_char(FONT_IX, ch, x, y, op);
x += FONT_IX->frame_x;
} else {
/*
if (ch & 0x10) {
ctx->regs.b.ixl = *str++;
ctx->regs.b.ixh = *str++;
}
if (ch & 0x1)
ctx->regs.b.e = *str++;
if (ch & 0x2)
ctx->regs.b.d = *str++;
if (ch & 0x4)
ctx->regs.b.c = *str++;
*/
// TODO: only can change font
}
} while (1);
}
@ -278,7 +352,7 @@ void STRDIS(ContextBlock *ctx) {
char* str = (char*) ctx->regs.w.hl;
void* fontdesc = (void*) ctx->regs.w.ix;
hw_xpand = opts & 0xf;
draw_string(str, x, y, 3&(opts>>4)); // TODO: opts
draw_string(ctx, str, x, y, 3&(opts>>4)); // TODO: opts
}
// Character display routine
@ -290,6 +364,12 @@ void CHRDIS(ContextBlock *ctx) {
STRDIS(ctx);
}
typedef struct {
sbyte xofs, yofs;
byte xsize, ysize;
byte pattern[0];
} PatternBlock;
const SysCallEntry SYSCALL_TABLE[64] = {
/* 0 */
{ &INTPC, 0 },
@ -300,7 +380,7 @@ const SysCallEntry SYSCALL_TABLE[64] = {
/* 10 */
{ 0, 0 },
{ 0, 0 },
{ 0, 0 },
{ &ACTINT, 0 },
{ 0, 0 },
{ 0, 0 },
/* 20 */
@ -420,10 +500,14 @@ void SYSCALL(ContextBlock *ctx) {
#ifdef TEST
void main() {
__asm
ld hl,#0x20d
push hl
pop ix
RST 0x38
.db 0 ; INTPC
.db 22+1 ; SETOUT
.db 102*2, 0x1c, 0x08
.db 14 ; ACTINT
.db 24+1 ; COLSET
.dw _main ; palette???
.db 26+1 ; FILL
@ -435,17 +519,42 @@ __asm
.db 32
.db 0x0c
.dw HelloString
.db 52+1 ; draw string
.db 0
.db 48
.db 0x0c
.dw HelloString
.db 50+1 ; draw char
.db 0
.db 64
.db 0x0c
.db 65
.db 0x40
.db 2 ; EXIT
jp .end
.loop:
ld hl,#0x4FED
ld a,(hl)
add a,#0x30
RST 0x38
.db 50 ; draw char
jp .loop
HelloString:
.ascii "HELLO WORLD!"
.db 0
.end:
.ascii "HELLO WORLD! "
.db 0xc1, 0xc2, 0xc3, 0xc4, 0xc5
.db 0
; Critter Pattern
; Color 0 = White and Color 2 = Black
;
PATERN: .DB 0,0 ; (0,0) Position
.DB 0x02,0x08 ; 2 byte, 8 line pattern size
.DB 0x0A,0xA0 ; 0000101010100000 - . . 2 2 2 2 . .
.DB 0x22,0x88 ; 0010001010001000 - . 2 . 2 2 . 2 .
.DB 0xAA,0xAA ; 1010101010101010 - 2 2 2 2 2 2 2 2
.DB 0x2A,0xA8 ; 0010101010101000 - . 2 2 2 2 2 2 .
.DB 0x08,0x20 ; 0000100000100000 - . . 2 . . 2 . .
.DB 0x20,0x08 ; 0010000000001000 - . 2 . . . . 2 .
.DB 0x08,0x20 ; 0000100000100000 - . . 2 . . 2 . .
.DB 0x00,0x00 ; 0000000000000000 - . . . . . . . .
__endasm;
while (1) CT[0]++;
}

View File

@ -186,14 +186,8 @@ function renderGlyph(glyph, putPixel) {
var xx = x+dx;
var yy = y+dy;
yy += params.yoffset || 0;
/*
font.pixbounds[0] = Math.min(font.pixbounds[0], xx);
font.pixbounds[1] = Math.min(font.pixbounds[1], yy);
font.pixbounds[2] = Math.max(font.pixbounds[2], xx);
font.pixbounds[3] = Math.max(font.pixbounds[3], yy);
*/
var xoutrange = xx < 0 || x >= params.width;
var youtrange = yy < 0 || y >= params.width;
var youtrange = yy < 0 || y >= params.height;
if (!xoutrange && !youtrange) {
putPixel(xx, yy);
} else if (!error_logged) {
@ -250,8 +244,6 @@ function previewFont() {
function encodeGlyph(glyph, bytes) {
var abort = false;
renderGlyph(glyph, function(x,y) {
//x -= font.pixbounds[0];
//y -= font.pixbounds[1];
if (params.yflip) { y = params.height-1-y; }
if (params.xflip ^ params.rotate) { x = params.width-1-x; }
if (params.rotate) {