diff --git a/presets/astrocade/acbios.h b/presets/astrocade/acbios.h index 744f6b6a..b042fe4e 100644 --- a/presets/astrocade/acbios.h +++ b/presets/astrocade/acbios.h @@ -16,12 +16,6 @@ typedef struct { const FontDescriptor __at(0x206) FNTSYS; const FontDescriptor __at(0x20d) FNTSML; -// STACK MANIPULATION - -#define DECSP1 __asm__("dec sp") -#define DECSP2 __asm__("dec sp"); __asm__("dec sp") -#define DECSP3 __asm__("dec sp"); __asm__("dec sp"); __asm__("dec sp") - // BIOS COMMANDS #define STRDIS 0x34 @@ -40,20 +34,9 @@ const FontDescriptor __at(0x20d) FNTSML; void activate_interrupts(void); void wait_for_vsync(void); -void _display_string(byte x, byte y, byte options, const char* str); -#define display_string(x,y,opts,str) \ - DECSP1; \ - _display_string(x,y,opts,str); - -void _paint_rectangle(byte x, byte y, byte w, byte h, byte colormask); -#define paint_rectangle(x,y,w,h,colormask) \ - DECSP1; \ - _paint_rectangle(x,y,w,h,colormask); - -void _write_relative(byte x, byte y, byte magic, const char* pattern); -#define write_relative(x,y,magic,pattern) \ - DECSP1; \ - _write_relative(x,y,magic,pattern); +void display_string(byte x, byte y, byte options, const char* str); +void paint_rectangle(byte x, byte y, byte w, byte h, byte colormask); +void write_relative(byte x, byte y, byte magic, const char* pattern); // QUICK MACROS diff --git a/presets/astrocade/acbios.s b/presets/astrocade/acbios.s index fe1c3a2d..f189f763 100644 --- a/presets/astrocade/acbios.s +++ b/presets/astrocade/acbios.s @@ -421,10 +421,10 @@ _wait_for_vsync: ; .db 1 ; build a SYSSUK block on the stack -; the caller needs to dec SP before calling -; so we have room for a RET opcode - .globl __display_string -__display_string: +; <5 bytes> +; rst <5 bytes> ret + .globl _display_string +_display_string: ld h,#(STRDIS+1) syssuk5: pop de ; return address @@ -432,21 +432,36 @@ syssuk5: push hl ; SYSSUK ld iy,#0 add iy,sp ; SP -> IY + ld ix,#7 + add ix,sp ; SP+7 -> IX push de ; push return addr + ld e,(ix) ; load what's there + push de ; push it ld d,#0xc9 ; ret opcode - ld 7(iy),d ; store after params + ld (ix),d ; store after params + ld hl,#endsuk5 + push hl ld ix,#0x20d ; alternate font desc. jp (iy) ; jump to RST +endsuk5: + pop de ; old ret value + pop hl ; return address + ld ix,#7 + add ix,sp ; SP+7 -> IX + ld (ix),e ; restore old ret value + pop de ; get rid of SYSSUK cmd + jp (hl) ; caller takes care of rest + ; RECTAN x y w h colormask - .globl __paint_rectangle -__paint_rectangle: + .globl _paint_rectangle +_paint_rectangle: ld h,#(RECTAN+1) jp syssuk5 ; WRITP x y magic pattern - .globl __write_relative -__write_relative: + .globl _write_relative +_write_relative: ld h,#(WRITR+1) jp syssuk5 diff --git a/presets/astrocade/vsync.c b/presets/astrocade/vsync.c index a00a36e7..ef9f565b 100644 --- a/presets/astrocade/vsync.c +++ b/presets/astrocade/vsync.c @@ -8,12 +8,15 @@ //#link "acbios.s" const byte player_bitmap[] = -{3,14,/*{w:12,h:16,bpp:2,brev:1}*/0x00,0x3C,0x00,0x00,0x18,0x00,0x00,0x3C,0x00,0x00,0x18,0x00,0x04,0x18,0x20,0x0C,0x3C,0x30,0x3C,0x3C,0x3C,0x1F,0xE7,0xF4,0x1F,0x66,0xF4,0x17,0xE7,0xE4,0x17,0xE7,0xE4,0x1C,0x7E,0x34,0x1C,0xFF,0x34,0x3C,0x18,0x3C,0x0C,0x18,0x30,0x04,0x18,0x20}; +{0,0, // X, Y offset + 3,14, // width (bytes) and height (lines) + /*{w:12,h:16,bpp:2,brev:1}*/ + 0x00,0x3C,0x00,0x00,0x18,0x00,0x00,0x3C,0x00,0x00,0x18,0x00,0x04,0x18,0x20,0x0C,0x3C,0x30,0x3C,0x3C,0x3C,0x1F,0xE7,0xF4,0x1F,0x66,0xF4,0x17,0xE7,0xE4,0x17,0xE7,0xE4,0x1C,0x7E,0x34,0x1C,0xFF,0x34,0x3C,0x18,0x3C,0x0C,0x18,0x30,0x04,0x18,0x20}; /*{pal:"astrocade",layout:"astrocade"}*/ const byte palette[8] = { - 0x06, 0x62, 0xF1, 0x04, - 0x07, 0xD4, 0x35, 0x01, + 0x07, 0xD4, 0x33, 0x01, + 0x07, 0xD4, 0x33, 0x01, }; void setup_registers() { @@ -24,16 +27,17 @@ void setup_registers() { void main() { byte x,y; - x=10; - y=10; + x=20; + y=20; setup_registers(); clrscr(); activate_interrupts(); while (1) { - render_sprite(player_bitmap, x, y, M_MOVE); + write_relative(x, y, M_MOVE, player_bitmap); wait_for_vsync(); - erase_sprite(player_bitmap, x, y); x++; - y++; +// erase_sprite(player_bitmap, x, y); +// x++; +// y++; } }