From 88574c87c4a87fdc3aec7d7eef30bf4702495efd Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 23 Nov 2024 21:21:52 +0100 Subject: [PATCH] convert vtui and zsmkit to new extsub address expression capability --- docs/source/todo.rst | 5 --- examples/cx16/vtui/testvtui.p8 | 45 +++++++++++------------ examples/cx16/zsmkit/demo2.p8 | 2 +- examples/cx16/zsmkit/zsmkit_high.p8 | 55 +++++++++++++++-------------- examples/cx16/zsmkit/zsmkit_low.p8 | 55 +++++++++++++++-------------- 5 files changed, 80 insertions(+), 82 deletions(-) diff --git a/docs/source/todo.rst b/docs/source/todo.rst index e76e4951a..224524903 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,16 +1,11 @@ TODO ==== - fix weird error messages for long vars long @shared foo2 = 123456 what to do with bnk(): it's an awkward name but bank() is too general a name and will forbid you to use 'bank' as a variable... add a function like addr() or lsw() to complement bnk() in getting easy access to the lower 16 bits of a long integer? -convert examples/cx16/vtui/testvtui.p8 and zsmkit to new extsub addr capability - - - ... diff --git a/examples/cx16/vtui/testvtui.p8 b/examples/cx16/vtui/testvtui.p8 index 2a3c99373..abb33c469 100644 --- a/examples/cx16/vtui/testvtui.p8 +++ b/examples/cx16/vtui/testvtui.p8 @@ -122,28 +122,29 @@ vtui $1000 { ; NOTE: base address $1000 here must be the same as the block's memory address, for obvious reasons! ; The routines below are for VTUI 1.0 - extsub $1000 = initialize() clobbers(A, X, Y) - extsub $1002 = screen_set(ubyte mode @A) clobbers(A, X, Y) - extsub $1005 = set_bank(bool bank1 @Pc) clobbers(A) - extsub $1008 = set_stride(ubyte stride @A) clobbers(A) - extsub $100b = set_decr(bool incrdecr @Pc) clobbers(A) - extsub $100e = clr_scr(ubyte char @A, ubyte colors @X) clobbers(Y) - extsub $1011 = gotoxy(ubyte column @A, ubyte row @Y) - extsub $1014 = plot_char(ubyte char @A, ubyte colors @X) - extsub $1017 = scan_char() -> ubyte @A, ubyte @X - extsub $101a = hline(ubyte char @A, ubyte length @Y, ubyte colors @X) clobbers(A) - extsub $101d = vline(ubyte char @A, ubyte height @Y, ubyte colors @X) clobbers(A) - extsub $1020 = print_str(str txtstring @R0, ubyte length @Y, ubyte colors @X, ubyte convertchars @A) clobbers(A, Y) - extsub $1023 = fill_box(ubyte char @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(A, Y) - extsub $1026 = pet2scr(ubyte char @A) -> ubyte @A - extsub $1029 = scr2pet(ubyte char @A) -> ubyte @A - extsub $102c = border(ubyte mode @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(Y) ; NOTE: mode 6 means 'custom' characters taken from r3 - r6 - extsub $102f = save_rect(ubyte ramtype @A, bool vbank1 @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y) - extsub $1032 = rest_rect(ubyte ramtype @A, bool vbank1 @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y) - extsub $1035 = input_str(uword buffer @R0, ubyte buflen @Y, ubyte colors @X) clobbers (A) -> ubyte @Y ; Y=length of input - extsub $1038 = get_bank() clobbers (A) -> bool @Pc - extsub $103b = get_stride() -> ubyte @A - extsub $103e = get_decr() clobbers (A) -> bool @Pc + const uword vtjmp = $1002 + extsub vtjmp - 2 = initialize() clobbers(A, X, Y) + extsub vtjmp + 0*3 = screen_set(ubyte mode @A) clobbers(A, X, Y) + extsub vtjmp + 1*3 = set_bank(bool bank1 @Pc) clobbers(A) + extsub vtjmp + 2*3 = set_stride(ubyte stride @A) clobbers(A) + extsub vtjmp + 3*3 = set_decr(bool incrdecr @Pc) clobbers(A) + extsub vtjmp + 4*3 = clr_scr(ubyte char @A, ubyte colors @X) clobbers(Y) + extsub vtjmp + 5*3 = gotoxy(ubyte column @A, ubyte row @Y) + extsub vtjmp + 6*3 = plot_char(ubyte char @A, ubyte colors @X) + extsub vtjmp + 7*3 = scan_char() -> ubyte @A, ubyte @X + extsub vtjmp + 8*3 = hline(ubyte char @A, ubyte length @Y, ubyte colors @X) clobbers(A) + extsub vtjmp + 9*3 = vline(ubyte char @A, ubyte height @Y, ubyte colors @X) clobbers(A) + extsub vtjmp + 10*3 = print_str(str txtstring @R0, ubyte length @Y, ubyte colors @X, ubyte convertchars @A) clobbers(A, Y) + extsub vtjmp + 11*3 = fill_box(ubyte char @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(A, Y) + extsub vtjmp + 12*3 = pet2scr(ubyte char @A) -> ubyte @A + extsub vtjmp + 13*3 = scr2pet(ubyte char @A) -> ubyte @A + extsub vtjmp + 14*3 = border(ubyte mode @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(Y) ; NOTE: mode 6 means 'custom' characters taken from r3 - r6 + extsub vtjmp + 15*3 = save_rect(ubyte ramtype @A, bool vbank1 @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y) + extsub vtjmp + 16*3 = rest_rect(ubyte ramtype @A, bool vbank1 @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y) + extsub vtjmp + 17*3 = input_str(uword buffer @R0, ubyte buflen @Y, ubyte colors @X) clobbers (A) -> ubyte @Y ; Y=length of input + extsub vtjmp + 18*3 = get_bank() clobbers (A) -> bool @Pc + extsub vtjmp + 19*3 = get_stride() -> ubyte @A + extsub vtjmp + 20*3 = get_decr() clobbers (A) -> bool @Pc ; -- helper function to do string length counting for you internally, and turn the convertchars flag into a boolean again asmsub print_str2(str txtstring @R0, ubyte colors @X, bool convertchars @Pc) clobbers(A, Y) { diff --git a/examples/cx16/zsmkit/demo2.p8 b/examples/cx16/zsmkit/demo2.p8 index c17ff3d3b..826abc591 100644 --- a/examples/cx16/zsmkit/demo2.p8 +++ b/examples/cx16/zsmkit/demo2.p8 @@ -13,7 +13,7 @@ main { const ubyte zsmkit_bank = 1 sub start() { - txt.print("zsmkit demo program (dynamic loading)\n") + txt.print("zsmkit demo program (preloaded)\n") load_and_init_zsmkit(iso:"lib/zsmkit-8c00.bin") load_music_file(iso:"music/MUSIC.ZSM") diff --git a/examples/cx16/zsmkit/zsmkit_high.p8 b/examples/cx16/zsmkit/zsmkit_high.p8 index 9ee184b70..ccb669174 100644 --- a/examples/cx16/zsmkit/zsmkit_high.p8 +++ b/examples/cx16/zsmkit/zsmkit_high.p8 @@ -2,34 +2,35 @@ ; extubs for zsmkit loaded at $8c00 zsmkit { - extsub $8C00 = zsm_init_engine(ubyte bank @A) clobbers(A, X, Y) - extsub $8C03 = zsm_tick(ubyte type @A) clobbers(A, X, Y) + const uword zsmjmp = $8c00 + extsub zsmjmp + 0*3 = zsm_init_engine(ubyte bank @A) clobbers(A, X, Y) + extsub zsmjmp + 1*3 = zsm_tick(ubyte type @A) clobbers(A, X, Y) - extsub $8C06 = zsm_play(ubyte prio @X) clobbers(A, X, Y) - extsub $8C09 = zsm_stop(ubyte prio @X) clobbers(A, X, Y) - extsub $8C0C = zsm_rewind(ubyte prio @X) clobbers(A, X, Y) - extsub $8C0F = zsm_close(ubyte prio @X) clobbers(A, X, Y) - extsub $8C12 = zsm_fill_buffers() clobbers(A, X, Y) - extsub $8C15 = zsm_setlfs(ubyte prio @X, ubyte lfn_sa @A, ubyte device @Y) clobbers(A, X, Y) - extsub $8C18 = zsm_setfile(ubyte prio @X, str filename @AY) clobbers(A, X, Y) - extsub $8C1B = zsm_loadpcm(ubyte prio @X, uword data_ptr @AY) clobbers(X) -> uword @AY - extsub $8C1E = zsm_setmem(ubyte prio @X, uword data_ptr @AY) clobbers(A, X, Y) - extsub $8C21 = zsm_setatten(ubyte prio @X, ubyte value @A) clobbers(A, X, Y) - extsub $8C24 = zsm_setcb(ubyte prio @X, uword func_ptr @AY) clobbers(A, X, Y) - extsub $8C27 = zsm_clearcb(ubyte prio @X) clobbers(A, X, Y) - extsub $8C2A = zsm_getstate(ubyte prio @X) clobbers(X) -> bool @Pc, bool @Pz, uword @AY - extsub $8C2D = zsm_setrate(ubyte prio @X, uword rate @AY) clobbers(A, X, Y) - extsub $8C30 = zsm_getrate(ubyte prio @X) clobbers() -> uword @AY - extsub $8C33 = zsm_setloop(ubyte prio @X, bool loop @Pc) clobbers(A, X, Y) - extsub $8C36 = zsm_opmatten(ubyte prio @X, ubyte channel @Y, ubyte value @A) clobbers(A, X, Y) - extsub $8C39 = zsm_psgatten(ubyte prio @X, ubyte channel @Y, ubyte value @A) clobbers(A, X, Y) - extsub $8C3C = zsm_pcmatten(ubyte prio @X, ubyte value @A) clobbers(A, X, Y) - extsub $8C3F = zsm_set_int_rate(ubyte value @A, ubyte frac @Y) clobbers(A, X, Y) + extsub zsmjmp + 2*3 = zsm_play(ubyte prio @X) clobbers(A, X, Y) + extsub zsmjmp + 3*3 = zsm_stop(ubyte prio @X) clobbers(A, X, Y) + extsub zsmjmp + 4*3 = zsm_rewind(ubyte prio @X) clobbers(A, X, Y) + extsub zsmjmp + 5*3 = zsm_close(ubyte prio @X) clobbers(A, X, Y) + extsub zsmjmp + 6*3 = zsm_fill_buffers() clobbers(A, X, Y) + extsub zsmjmp + 7*3 = zsm_setlfs(ubyte prio @X, ubyte lfn_sa @A, ubyte device @Y) clobbers(A, X, Y) + extsub zsmjmp + 8*3 = zsm_setfile(ubyte prio @X, str filename @AY) clobbers(A, X, Y) + extsub zsmjmp + 9*3 = zsm_loadpcm(ubyte prio @X, uword data_ptr @AY) clobbers(X) -> uword @AY + extsub zsmjmp + 10*3 = zsm_setmem(ubyte prio @X, uword data_ptr @AY) clobbers(A, X, Y) + extsub zsmjmp + 11*3 = zsm_setatten(ubyte prio @X, ubyte value @A) clobbers(A, X, Y) + extsub zsmjmp + 12*3 = zsm_setcb(ubyte prio @X, uword func_ptr @AY) clobbers(A, X, Y) + extsub zsmjmp + 13*3 = zsm_clearcb(ubyte prio @X) clobbers(A, X, Y) + extsub zsmjmp + 14*3 = zsm_getstate(ubyte prio @X) clobbers(X) -> bool @Pc, bool @Pz, uword @AY + extsub zsmjmp + 15*3 = zsm_setrate(ubyte prio @X, uword rate @AY) clobbers(A, X, Y) + extsub zsmjmp + 16*3 = zsm_getrate(ubyte prio @X) clobbers() -> uword @AY + extsub zsmjmp + 17*3 = zsm_setloop(ubyte prio @X, bool loop @Pc) clobbers(A, X, Y) + extsub zsmjmp + 18*3 = zsm_opmatten(ubyte prio @X, ubyte channel @Y, ubyte value @A) clobbers(A, X, Y) + extsub zsmjmp + 19*3 = zsm_psgatten(ubyte prio @X, ubyte channel @Y, ubyte value @A) clobbers(A, X, Y) + extsub zsmjmp + 20*3 = zsm_pcmatten(ubyte prio @X, ubyte value @A) clobbers(A, X, Y) + extsub zsmjmp + 21*3 = zsm_set_int_rate(ubyte value @A, ubyte frac @Y) clobbers(A, X, Y) - extsub $8C4B = zcm_setmem(ubyte slot @X, uword data_ptr @AY) clobbers(A) - extsub $8C4E = zcm_play(ubyte slot @X, ubyte volume @A) clobbers(A, X) - extsub $8C51 = zcm_stop() clobbers(A) + extsub zsmjmp + 25*3 = zcm_setmem(ubyte slot @X, uword data_ptr @AY) clobbers(A) + extsub zsmjmp + 26*3 = zcm_play(ubyte slot @X, ubyte volume @A) clobbers(A, X) + extsub zsmjmp + 27*3 = zcm_stop() clobbers(A) - extsub $8C54 = zsmkit_setisr() clobbers(A) - extsub $8C57 = zsmkit_clearisr() clobbers(A) + extsub zsmjmp + 28*3 = zsmkit_setisr() clobbers(A) + extsub zsmjmp + 29*3 = zsmkit_clearisr() clobbers(A) } diff --git a/examples/cx16/zsmkit/zsmkit_low.p8 b/examples/cx16/zsmkit/zsmkit_low.p8 index 8b99c20d1..17ecae8bf 100644 --- a/examples/cx16/zsmkit/zsmkit_low.p8 +++ b/examples/cx16/zsmkit/zsmkit_low.p8 @@ -2,34 +2,35 @@ ; extsubs for zsmkit loaded at $0830 zsmkit { - extsub $0830 = zsm_init_engine(ubyte bank @A) clobbers(A, X, Y) - extsub $0833 = zsm_tick(ubyte type @A) clobbers(A, X, Y) + const uword zsmjmp = $0830 + extsub zsmjmp + 0*3 = zsm_init_engine(ubyte bank @A) clobbers(A, X, Y) + extsub zsmjmp + 1*3 = zsm_tick(ubyte type @A) clobbers(A, X, Y) - extsub $0836 = zsm_play(ubyte prio @X) clobbers(A, X, Y) - extsub $0839 = zsm_stop(ubyte prio @X) clobbers(A, X, Y) - extsub $083c = zsm_rewind(ubyte prio @X) clobbers(A, X, Y) - extsub $083f = zsm_close(ubyte prio @X) clobbers(A, X, Y) - extsub $0842 = zsm_fill_buffers() clobbers(A, X, Y) - extsub $0845 = zsm_setlfs(ubyte prio @X, ubyte lfn_sa @A, ubyte device @Y) clobbers(A, X, Y) - extsub $0848 = zsm_setfile(ubyte prio @X, str filename @AY) clobbers(A, X, Y) - extsub $084b = zsm_loadpcm(ubyte prio @X, uword data_ptr @AY) clobbers(X) -> uword @AY - extsub $084e = zsm_setmem(ubyte prio @X, uword data_ptr @AY) clobbers(A, X, Y) - extsub $0851 = zsm_setatten(ubyte prio @X, ubyte value @A) clobbers(A, X, Y) - extsub $0854 = zsm_setcb(ubyte prio @X, uword func_ptr @AY) clobbers(A, X, Y) - extsub $0857 = zsm_clearcb(ubyte prio @X) clobbers(A, X, Y) - extsub $085A = zsm_getstate(ubyte prio @X) clobbers(X) -> bool @Pc, bool @Pz, uword @AY - extsub $085D = zsm_setrate(ubyte prio @X, uword rate @AY) clobbers(A, X, Y) - extsub $0860 = zsm_getrate(ubyte prio @X) clobbers() -> uword @AY - extsub $0863 = zsm_setloop(ubyte prio @X, bool loop @Pc) clobbers(A, X, Y) - extsub $0866 = zsm_opmatten(ubyte prio @X, ubyte channel @Y, ubyte value @A) clobbers(A, X, Y) - extsub $0869 = zsm_psgatten(ubyte prio @X, ubyte channel @Y, ubyte value @A) clobbers(A, X, Y) - extsub $086C = zsm_pcmatten(ubyte prio @X, ubyte value @A) clobbers(A, X, Y) - extsub $086F = zsm_set_int_rate(ubyte value @A, ubyte frac @Y) clobbers(A, X, Y) + extsub zsmjmp + 2*3 = zsm_play(ubyte prio @X) clobbers(A, X, Y) + extsub zsmjmp + 3*3 = zsm_stop(ubyte prio @X) clobbers(A, X, Y) + extsub zsmjmp + 4*3 = zsm_rewind(ubyte prio @X) clobbers(A, X, Y) + extsub zsmjmp + 5*3 = zsm_close(ubyte prio @X) clobbers(A, X, Y) + extsub zsmjmp + 6*3 = zsm_fill_buffers() clobbers(A, X, Y) + extsub zsmjmp + 7*3 = zsm_setlfs(ubyte prio @X, ubyte lfn_sa @A, ubyte device @Y) clobbers(A, X, Y) + extsub zsmjmp + 8*3 = zsm_setfile(ubyte prio @X, str filename @AY) clobbers(A, X, Y) + extsub zsmjmp + 9*3 = zsm_loadpcm(ubyte prio @X, uword data_ptr @AY) clobbers(X) -> uword @AY + extsub zsmjmp + 10*3 = zsm_setmem(ubyte prio @X, uword data_ptr @AY) clobbers(A, X, Y) + extsub zsmjmp + 11*3 = zsm_setatten(ubyte prio @X, ubyte value @A) clobbers(A, X, Y) + extsub zsmjmp + 12*3 = zsm_setcb(ubyte prio @X, uword func_ptr @AY) clobbers(A, X, Y) + extsub zsmjmp + 13*3 = zsm_clearcb(ubyte prio @X) clobbers(A, X, Y) + extsub zsmjmp + 14*3 = zsm_getstate(ubyte prio @X) clobbers(X) -> bool @Pc, bool @Pz, uword @AY + extsub zsmjmp + 15*3 = zsm_setrate(ubyte prio @X, uword rate @AY) clobbers(A, X, Y) + extsub zsmjmp + 16*3 = zsm_getrate(ubyte prio @X) clobbers() -> uword @AY + extsub zsmjmp + 17*3 = zsm_setloop(ubyte prio @X, bool loop @Pc) clobbers(A, X, Y) + extsub zsmjmp + 18*3 = zsm_opmatten(ubyte prio @X, ubyte channel @Y, ubyte value @A) clobbers(A, X, Y) + extsub zsmjmp + 19*3 = zsm_psgatten(ubyte prio @X, ubyte channel @Y, ubyte value @A) clobbers(A, X, Y) + extsub zsmjmp + 29*3 = zsm_pcmatten(ubyte prio @X, ubyte value @A) clobbers(A, X, Y) + extsub zsmjmp + 21*3 = zsm_set_int_rate(ubyte value @A, ubyte frac @Y) clobbers(A, X, Y) - extsub $087B = zcm_setmem(ubyte slot @X, uword data_ptr @AY) clobbers(A) - extsub $087E = zcm_play(ubyte slot @X, ubyte volume @A) clobbers(A, X) - extsub $0881 = zcm_stop() clobbers(A) + extsub zsmjmp + 25*3 = zcm_setmem(ubyte slot @X, uword data_ptr @AY) clobbers(A) + extsub zsmjmp + 26*3 = zcm_play(ubyte slot @X, ubyte volume @A) clobbers(A, X) + extsub zsmjmp + 27*3 = zcm_stop() clobbers(A) - extsub $0884 = zsmkit_setisr() clobbers(A) - extsub $0887 = zsmkit_clearisr() clobbers(A) + extsub zsmjmp + 28*3 = zsmkit_setisr() clobbers(A) + extsub zsmjmp + 29*3 = zsmkit_clearisr() clobbers(A) }