From 9ece0ceb8c27dd1dd5b5337b7c0f4bdeb368a825 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 25 Sep 2021 22:44:07 -0400 Subject: [PATCH] peasant: move music playing to the language card this was a huge pain also had to remove all calls to the firmware --- games/peasant/Makefile | 20 ++- games/peasant/copy_check.s | 4 +- games/peasant/ending.s | 8 +- games/peasant/generate_common.c | 92 ++++++++++++++ games/peasant/hardware.inc | 6 +- games/peasant/hgr_hgr2.s | 58 +++++++++ games/peasant/hgr_tables.s | 50 +++++++- games/peasant/interrupt_handler.s | 4 +- games/peasant/intro.s | 8 +- games/peasant/music.inc | 35 ++++-- games/peasant/music.s | 4 + games/peasant/peasant1.s | 6 +- games/peasant/peasant2.s | 10 +- games/peasant/peasant3.s | 9 +- games/peasant/peasant4.s | 8 +- games/peasant/pt3_lib_mockingboard_patch.s | 120 ++++++++++++++++++ games/peasant/pt3_lib_mockingboard_setup.s | 139 ++------------------- games/peasant/qboot_stage2.s | 5 +- games/peasant/qload.inc | 22 ++-- games/peasant/qload.s | 21 ++-- games/peasant/title.s | 43 ++++++- games/peasant/trogdor.s | 7 +- games/peasant/vid_logo.s | 17 ++- games/peasant/wait.s | 14 +++ games/peasant/wait_a_bit.s | 2 +- games/peasant/zp.inc | 1 + 26 files changed, 504 insertions(+), 209 deletions(-) create mode 100644 games/peasant/generate_common.c create mode 100644 games/peasant/hgr_hgr2.s create mode 100644 games/peasant/pt3_lib_mockingboard_patch.s create mode 100644 games/peasant/wait.s diff --git a/games/peasant/Makefile b/games/peasant/Makefile index 9638ca66..28578545 100644 --- a/games/peasant/Makefile +++ b/games/peasant/Makefile @@ -69,7 +69,16 @@ wrong_boot2.o: wrong_boot2.s ### +generate_common: generate_common.o + $(CC) $(LFLAGS) -o generate_common generate_common.o +generate_common.o: generate_common.c + $(CC) $(CFLAGS) -c generate_common.c + +#### + +music.inc: generate_common MUSIC + ./generate_common > music.inc ### @@ -85,10 +94,11 @@ vid_logo.o: vid_logo.s decompress_fast_v2.s hgr_overlay.s speaker_beeps.s \ TITLE: title.o ld65 -o TITLE title.o -C $(LINKER_SCRIPTS)/apple2_6000.inc -title.o: title.s \ +title.o: title.s music.inc \ graphics_title/title_graphics.inc \ graphics_title/altfire.inc \ - directions.s + directions.s \ + pt3_lib_mockingboard_patch.s ca65 -o title.o title.s -l title.lst ### @@ -96,7 +106,7 @@ title.o: title.s \ INTRO: intro.o ld65 -o INTRO intro.o -C $(LINKER_SCRIPTS)/apple2_6000.inc -intro.o: intro.s zp.inc \ +intro.o: intro.s zp.inc qload.inc music.inc \ graphics/graphics_intro.inc sprites/peasant_sprite.inc \ draw_box.s hgr_rectangle.s hgr_font.s hgr_input.s \ hgr_7x28_sprite.s hgr_1x5_sprite.s hgr_save_restore.s \ @@ -208,7 +218,7 @@ trogdor.o: trogdor.s zp.inc \ ENDING: ending.o ld65 -o ENDING ending.o -C $(LINKER_SCRIPTS)/apple2_6000.inc -ending.o: ending.s zp.inc \ +ending.o: ending.s zp.inc qload.inc music.inc \ graphics_end/ending_graphics.inc sprites/peasant_sprite.inc \ sprites/ending_sprites.inc \ draw_box.s hgr_rectangle.s hgr_font.s hgr_input.s \ @@ -299,5 +309,5 @@ sprites/trogdor_sprites.inc: clean: rm -f *~ *.o *.lst HELLO VID_LOGO TITLE INTRO COPY_CHECK \ PEASANT1 PEASANT2 PEASANT3 PEASANT4 \ - TROGDOR ENDING + TROGDOR ENDING MUSIC diff --git a/games/peasant/copy_check.s b/games/peasant/copy_check.s index 234919b4..13de7d35 100644 --- a/games/peasant/copy_check.s +++ b/games/peasant/copy_check.s @@ -21,8 +21,7 @@ copy_check: jsr hgr_make_tables - jsr HGR2 ; Hi-res graphics, no text at bottom - ; Y=0, A=0 after this called + jsr hgr2 trogdor_question: @@ -121,6 +120,7 @@ forever: .include "hgr_tables.s" .include "hgr_text_box.s" .include "hgr_partial_save.s" +.include "hgr_hgr2.s" .include "graphics_copy/copy_graphics.inc" diff --git a/games/peasant/ending.s b/games/peasant/ending.s index 7d3d9ac6..fc5c6606 100644 --- a/games/peasant/ending.s +++ b/games/peasant/ending.s @@ -8,6 +8,7 @@ .include "zp.inc" .include "qload.inc" +.include "music.inc" ending: @@ -15,8 +16,7 @@ ending: jsr hgr_make_tables - jsr HGR2 ; Hi-res graphics, no text at bottom - ; Y=0, A=0 after this called + jsr hgr2 lda #0 @@ -331,7 +331,7 @@ same_baby: no_draw_baby: lda #150 - jsr WAIT + jsr wait inc FRAME @@ -557,9 +557,11 @@ peasant_text: .include "hgr_14x14_sprite_mask.s" .include "hgr_sprite.s" +.include "hgr_hgr2.s" .include "score.s" +.include "wait.s" .include "wait_a_bit.s" .include "speaker_beeps.s" diff --git a/games/peasant/generate_common.c b/games/peasant/generate_common.c new file mode 100644 index 00000000..dd10a7ab --- /dev/null +++ b/games/peasant/generate_common.c @@ -0,0 +1,92 @@ +#include +#include + +/* music */ +static char filename[]="music.lst"; +static int routine_offset=0xD000; + + +static FILE *fff; + + +static void find_address(char *symbol_name) { + + unsigned int addr=0; + char string[BUFSIZ],*result; + char temp_name[BUFSIZ]; + + sprintf(temp_name,"%s:",symbol_name); + + while(1) { + + result=fgets(string,BUFSIZ,fff); + if (result==NULL) break; + + result=strstr(string,temp_name); + if (result!=NULL) { + string[6]=0; + sscanf(string,"%x",&addr); + break; + } + } + + + printf("%s\t=$%04x\n",symbol_name,addr+routine_offset); +} + +int main(int argc, char **argv) { + + fff=fopen(filename,"r"); + if (fff==NULL) { + fprintf(stderr,"ERROR! could not open %s\n",filename); + return -1; + } + + printf(";=============================\n"); + printf("; external routines\n"); + printf("\n"); + +// printf("; loader.s\n"); +// find_address("opendir_filename"); +// printf("\n"); + +// printf("; audio.s\n"); +// find_address("play_audio"); +// printf("\n"); + + printf(";\n"); + find_address("pt3_init_song"); + printf("\n"); + + printf(";\n"); + find_address("mockingboard_init"); + printf("\n"); + + printf(";\n"); + find_address("reset_ay_both"); + printf("\n"); + + printf(";\n"); + find_address("clear_ay_both"); + printf("\n"); + + printf(";\n"); + find_address("mockingboard_setup_interrupt"); + printf("\n"); + + printf(";\n"); + find_address("mockingboard_disable_interrupt"); + printf("\n"); + + printf(";\n"); + find_address("done_pt3_irq_handler"); + printf("\n"); + + printf(";\n"); + find_address("PT3_LOC"); + printf("\n"); + + fclose(fff); + + return 0; +} diff --git a/games/peasant/hardware.inc b/games/peasant/hardware.inc index ab34f518..ba2518a6 100644 --- a/games/peasant/hardware.inc +++ b/games/peasant/hardware.inc @@ -29,10 +29,10 @@ PTRIG = $C070 ; APPLESOFT BASIC ROUTINES ;NORMAL = $F273 -HGR2 = $F3D8 +;HGR2 = $F3D8 ;HGR = $F3E2 ;BKGND0 = $F3F4 ; clear current page to A -HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y) +;HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y) HPLOT0 = $F457 ; plot at (Y,X), (A) ;COLOR_SHIFT = $F47E ;HLINRL = $F530 ; (X,A),(Y) @@ -55,7 +55,7 @@ ROM_MACHINEID = $FBB3 ; iigs ;BASCALC = $FBC1 ; ;VTAB = $FC22 ; VTAB to CV HOME = $FC58 ; Clear the text screen ; qboot -WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us +;WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us ;CROUT1 = $FD8B ;SETINV = $FE80 ; INVERSE ;SETNORM = $FE84 ; NORMAL diff --git a/games/peasant/hgr_hgr2.s b/games/peasant/hgr_hgr2.s new file mode 100644 index 00000000..54af5271 --- /dev/null +++ b/games/peasant/hgr_hgr2.s @@ -0,0 +1,58 @@ + ;======================= + ; HGR2 Clearscreen + ;======================= + ; note, using BKGND0 for this takes 0x44198 = 278,936 cycles + ; unrolled here takes 0x0A501 = 42,241 cycles + +hgr2: + bit SET_GR + bit HIRES + bit PAGE2 + + lda #$40 + sta HGR_PAGE + + lda #$00 + +hgr2_clearscreen: + +before: + ldy #0 +hgr_cls_loop: + sta $2000,Y + sta $2100,Y + sta $2200,Y + sta $2300,Y + sta $2400,Y + sta $2500,Y + sta $2600,Y + sta $2700,Y + sta $2800,Y + sta $2900,Y + sta $2A00,Y + sta $2B00,Y + sta $2C00,Y + sta $2D00,Y + sta $2E00,Y + sta $2F00,Y + sta $3000,Y + sta $3100,Y + sta $3200,Y + sta $3300,Y + sta $3400,Y + sta $3500,Y + sta $3600,Y + sta $3700,Y + sta $3800,Y + sta $3900,Y + sta $3A00,Y + sta $3B00,Y + sta $3C00,Y + sta $3D00,Y + sta $3E00,Y + sta $3F00,Y + iny + bne hgr_cls_loop + +after: + rts diff --git a/games/peasant/hgr_tables.s b/games/peasant/hgr_tables.s index f1f270f8..4d95b196 100644 --- a/games/peasant/hgr_tables.s +++ b/games/peasant/hgr_tables.s @@ -50,7 +50,7 @@ hposn_loop: ldy #0 ldx #0 pha - jsr HPOSN ; (Y,X),(A) + jsr hposn ; (Y,X),(A) pla tax @@ -91,3 +91,51 @@ right_masks: .byte $81,$83,$87, $8F,$9F,$BF,$FF + + + ; from the Apple II firmware +hposn: +; sta HGR_Y ; save Y and X positions +; stx HGR_X +; sty HGR_X+1 + + pha ; Y pos on stack + + and #$C0 ; calc base addr for Y-pos + + sta GBASL + lsr + lsr + ora GBASL + sta GBASL + pla + + sta GBASH + asl + asl + asl + rol GBASH + asl + rol GBASH + asl + ror GBASL + lda GBASH + + and #$1F + + ora HGR_PAGE + sta GBASH + +; txa +; cpy #0 +; beq xpos_lessthan_256 +; ldy #35 +; adc #4 +;label_1: +; iny +;xpos_lessthan_256: +; sbc #7 +; bcs label_1 + + rts + diff --git a/games/peasant/interrupt_handler.s b/games/peasant/interrupt_handler.s index 2a766283..85da4909 100644 --- a/games/peasant/interrupt_handler.s +++ b/games/peasant/interrupt_handler.s @@ -27,8 +27,6 @@ interrupt_handler: tya pha ; save Y - - ; inc $0404 ; debug (flashes char onscreen) @@ -67,3 +65,5 @@ interrupt_smc: ; typical ; ???? cycles + + diff --git a/games/peasant/intro.s b/games/peasant/intro.s index 75ed257e..f2000635 100644 --- a/games/peasant/intro.s +++ b/games/peasant/intro.s @@ -8,8 +8,7 @@ .include "zp.inc" .include "qload.inc" - - +.include "music.inc" peasant_quest_intro: @@ -18,8 +17,7 @@ peasant_quest_intro: jsr hgr_make_tables - jsr HGR2 ; Hi-res graphics, no text at bottom - ; Y=0, A=0 after this called + jsr hgr2 ;******************************* @@ -174,7 +172,9 @@ escape_handler: .include "hgr_input.s" .include "hgr_tables.s" .include "hgr_text_box.s" +.include "hgr_hgr2.s" +.include "wait.s" .include "wait_a_bit.s" .include "graphics/graphics_intro.inc" diff --git a/games/peasant/music.inc b/games/peasant/music.inc index 012678c8..0264cc9a 100644 --- a/games/peasant/music.inc +++ b/games/peasant/music.inc @@ -1,14 +1,27 @@ -; Danger: if you mess with MUSIC you'll have to update these +;============================= +; external routines -MUSIC_LOC=$D000 -pt3_init_song=MUSIC_LOC+$8E8 -clear_ay_both=MUSIC_LOC+$B71 -reset_ay_both=MUSIC_LOC+$B2F -mockingboard_setup_interrupt=MUSIC_LOC+$B7E -mockingboard_disable_interrupt=MUSIC_LOC+$BA6 -mockingboard_init=MUSIC_LOC+$B20 -mockingboard_patch=MUSIC_LOC+$BB2 -mockingboard_detect=MUSIC_LOC+$C5D +; +pt3_init_song =$d8e9 -PT3_LOC=MUSIC_LOC+$D00 +; +mockingboard_init =$db21 + +; +reset_ay_both =$db30 + +; +clear_ay_both =$db72 + +; +mockingboard_setup_interrupt =$db7f + +; +mockingboard_disable_interrupt =$dbb9 + +; +done_pt3_irq_handler =$dc31 + +; +PT3_LOC =$dd00 diff --git a/games/peasant/music.s b/games/peasant/music.s index a2ea031a..31736758 100644 --- a/games/peasant/music.s +++ b/games/peasant/music.s @@ -8,6 +8,10 @@ ;.include "qload.inc" music_lib: + + nop ; urgh to keep interrupt_handler from starting at $C4 + ; which broke auto-patcher + ; pt3 player ; .include "pt3_lib_detect_model.s" .include "pt3_lib_core.s" diff --git a/games/peasant/peasant1.s b/games/peasant/peasant1.s index dae68dd8..733f7b79 100644 --- a/games/peasant/peasant1.s +++ b/games/peasant/peasant1.s @@ -21,7 +21,7 @@ peasant_quest: jsr hgr_make_tables - jsr HGR2 ; Hi-res graphics, no text at bottom + jsr hgr2 ; Hi-res graphics, no text at bottom ; Y=0, A=0 after this called @@ -127,7 +127,7 @@ game_loop: ; delay lda #200 - jsr WAIT + jsr wait jmp game_loop @@ -164,6 +164,7 @@ peasant_text: .include "hgr_tables.s" .include "hgr_text_box.s" .include "clear_bottom.s" +.include "hgr_hgr2.s" .include "gr_copy.s" @@ -179,6 +180,7 @@ peasant_text: .include "keyboard.s" +.include "wait.s" .include "wait_a_bit.s" .include "graphics/graphics_peasant1.inc" diff --git a/games/peasant/peasant2.s b/games/peasant/peasant2.s index af923519..db2baa30 100644 --- a/games/peasant/peasant2.s +++ b/games/peasant/peasant2.s @@ -20,11 +20,7 @@ peasant_quest: jsr hgr_make_tables - jsr HGR2 ; Hi-res graphics, no text at bottom - ; Y=0, A=0 after this called - - - + jsr hgr2 lda #0 @@ -130,7 +126,7 @@ game_loop: ; delay lda #200 - jsr WAIT + jsr wait jmp game_loop @@ -169,6 +165,7 @@ peasant_text: .include "hgr_tables.s" .include "hgr_text_box.s" .include "clear_bottom.s" +.include "hgr_hgr2.s" .include "gr_copy.s" @@ -181,6 +178,7 @@ peasant_text: .include "keyboard.s" +.include "wait.s" .include "wait_a_bit.s" .include "graphics/graphics_peasant2.inc" diff --git a/games/peasant/peasant3.s b/games/peasant/peasant3.s index 58568aa8..81891dfd 100644 --- a/games/peasant/peasant3.s +++ b/games/peasant/peasant3.s @@ -20,9 +20,7 @@ peasant_quest: jsr hgr_make_tables - jsr HGR2 ; Hi-res graphics, no text at bottom - ; Y=0, A=0 after this called - + jsr hgr2 @@ -130,8 +128,7 @@ game_loop: ; delay lda #200 - jsr WAIT - + jsr wait jmp game_loop @@ -167,6 +164,7 @@ peasant_text: .include "hgr_tables.s" .include "hgr_text_box.s" .include "clear_bottom.s" +.include "hgr_hgr2.s" .include "gr_copy.s" @@ -181,6 +179,7 @@ peasant_text: .include "keyboard.s" +.include "wait.s" .include "wait_a_bit.s" .include "graphics/graphics_peasant3.inc" diff --git a/games/peasant/peasant4.s b/games/peasant/peasant4.s index 0026323e..42b1954f 100644 --- a/games/peasant/peasant4.s +++ b/games/peasant/peasant4.s @@ -20,9 +20,7 @@ peasant_quest: jsr hgr_make_tables - jsr HGR2 ; Hi-res graphics, no text at bottom - ; Y=0, A=0 after this called - + jsr hgr2 @@ -129,7 +127,7 @@ game_loop: ; delay lda #200 - jsr WAIT + jsr wait jmp game_loop @@ -169,6 +167,7 @@ peasant_text: .include "hgr_tables.s" .include "hgr_text_box.s" .include "clear_bottom.s" +.include "hgr_hgr2.s" .include "gr_copy.s" @@ -184,6 +183,7 @@ peasant_text: .include "keyboard.s" +.include "wait.s" .include "wait_a_bit.s" .include "graphics/graphics_peasant4.inc" diff --git a/games/peasant/pt3_lib_mockingboard_patch.s b/games/peasant/pt3_lib_mockingboard_patch.s new file mode 100644 index 00000000..89665c64 --- /dev/null +++ b/games/peasant/pt3_lib_mockingboard_patch.s @@ -0,0 +1,120 @@ + +;=================================================================== +; code to patch mockingboard if not in slot#4 +;=================================================================== +; this is the brute force version, we have to patch 39 locations +; see further below if you want to try a smaller, more dangerous, patch + +.if 0 +mockingboard_patch: + + lda MB_ADDR_H + + sta pt3_irq_smc1+2 ; 1 + + sta pt3_irq_smc2+2 ; 2 + sta pt3_irq_smc2+5 ; 3 + + sta pt3_irq_smc3+2 ; 4 + sta pt3_irq_smc3+5 ; 5 + + sta pt3_irq_smc4+2 ; 6 + sta pt3_irq_smc4+5 ; 7 + + sta pt3_irq_smc5+2 ; 8 + sta pt3_irq_smc5+5 ; 9 + + sta pt3_irq_smc6+2 ; 10 + sta pt3_irq_smc6+5 ; 11 + + sta pt3_irq_smc7+2 ; 12 + sta pt3_irq_smc7+5 ; 13 + + sta mock_init_smc1+2 ; 14 + sta mock_init_smc1+5 ; 15 + + sta mock_init_smc2+2 ; 16 + sta mock_init_smc2+5 ; 17 + + sta reset_ay_smc1+2 ; 18 + sta reset_ay_smc2+2 ; 19 + sta reset_ay_smc3+2 ; 20 + sta reset_ay_smc4+2 ; 21 + + sta write_ay_smc1+2 ; 22 + sta write_ay_smc1+5 ; 23 + + sta write_ay_smc2+2 ; 24 + sta write_ay_smc2+5 ; 25 + + sta write_ay_smc3+2 ; 26 + sta write_ay_smc3+5 ; 27 + + sta write_ay_smc4+2 ; 28 + sta write_ay_smc4+5 ; 29 + + sta write_ay_smc5+2 ; 30 + sta write_ay_smc5+5 ; 31 + + sta write_ay_smc6+2 ; 32 + sta write_ay_smc6+5 ; 33 + + sta setup_irq_smc1+2 ; 34 + sta setup_irq_smc2+2 ; 35 + sta setup_irq_smc3+2 ; 36 + sta setup_irq_smc4+2 ; 37 + sta setup_irq_smc5+2 ; 38 + sta setup_irq_smc6+2 ; 39 + + rts +.endif + +;=================================================================== +; dangerous code to patch mockingboard if not in slot#4 +;=================================================================== +; this code patches any $C4 value to the proper slot# if not slot4 +; this can be dangerous, it might over-write other important values +; that should be $C4 + +; safer ways to do this: +; only do this if 2 bytes after a LDA/STA/LDX/STX +; count total and if not 39 then print error message + +mockingboard_patch: + ; from mockingboard_init $1BBF + ; to done_pt3_irq_handler $1D85 + + ldx MB_ADDR_H + ldy #0 + + lda #mockingboard_init + sta MB_ADDR_H + +mb_patch_loop: + lda (MB_ADDR_L),Y + cmp #$C4 + bne mb_patch_nomatch + + txa + sta (MB_ADDR_L),Y +mb_patch_nomatch: + + ; 16-bit increment + + inc MB_ADDR_L + bne mb_patch_oflo + inc MB_ADDR_H + +mb_patch_oflo: + lda MB_ADDR_H + cmp #>done_pt3_irq_handler + bne mb_patch_loop + lda MB_ADDR_L + cmp #interrupt_handler @@ -217,7 +221,7 @@ write_rom_loop: lda #$EA sta interrupt_smc sta interrupt_smc+1 -.endif +;.endif done_iic_hack: @@ -293,124 +297,3 @@ disable_irq_smc2: rts - - - -;=================================================================== -; code to patch mockingboard if not in slot#4 -;=================================================================== -; this is the brute force version, we have to patch 39 locations -; see further below if you want to try a smaller, more dangerous, patch - -.if 0 -mockingboard_patch: - - lda MB_ADDR_H - - sta pt3_irq_smc1+2 ; 1 - - sta pt3_irq_smc2+2 ; 2 - sta pt3_irq_smc2+5 ; 3 - - sta pt3_irq_smc3+2 ; 4 - sta pt3_irq_smc3+5 ; 5 - - sta pt3_irq_smc4+2 ; 6 - sta pt3_irq_smc4+5 ; 7 - - sta pt3_irq_smc5+2 ; 8 - sta pt3_irq_smc5+5 ; 9 - - sta pt3_irq_smc6+2 ; 10 - sta pt3_irq_smc6+5 ; 11 - - sta pt3_irq_smc7+2 ; 12 - sta pt3_irq_smc7+5 ; 13 - - sta mock_init_smc1+2 ; 14 - sta mock_init_smc1+5 ; 15 - - sta mock_init_smc2+2 ; 16 - sta mock_init_smc2+5 ; 17 - - sta reset_ay_smc1+2 ; 18 - sta reset_ay_smc2+2 ; 19 - sta reset_ay_smc3+2 ; 20 - sta reset_ay_smc4+2 ; 21 - - sta write_ay_smc1+2 ; 22 - sta write_ay_smc1+5 ; 23 - - sta write_ay_smc2+2 ; 24 - sta write_ay_smc2+5 ; 25 - - sta write_ay_smc3+2 ; 26 - sta write_ay_smc3+5 ; 27 - - sta write_ay_smc4+2 ; 28 - sta write_ay_smc4+5 ; 29 - - sta write_ay_smc5+2 ; 30 - sta write_ay_smc5+5 ; 31 - - sta write_ay_smc6+2 ; 32 - sta write_ay_smc6+5 ; 33 - - sta setup_irq_smc1+2 ; 34 - sta setup_irq_smc2+2 ; 35 - sta setup_irq_smc3+2 ; 36 - sta setup_irq_smc4+2 ; 37 - sta setup_irq_smc5+2 ; 38 - sta setup_irq_smc6+2 ; 39 - - rts -.endif - -;=================================================================== -; dangerous code to patch mockingboard if not in slot#4 -;=================================================================== -; this code patches any $C4 value to the proper slot# if not slot4 -; this can be dangerous, it might over-write other important values -; that should be $C4 - -; safer ways to do this: -; only do this if 2 bytes after a LDA/STA/LDX/STX -; count total and if not 39 then print error message - -mockingboard_patch: - ; from mockingboard_init $1BBF - ; to done_pt3_irq_handler $1D85 - - ldx MB_ADDR_H - ldy #0 - - lda #mockingboard_init - sta MB_ADDR_H - -mb_patch_loop: - lda (MB_ADDR_L),Y - cmp #$C4 - bne mb_patch_nomatch - - txa - sta (MB_ADDR_L),Y -mb_patch_nomatch: - - inc MB_ADDR_L - lda MB_ADDR_L - bne mb_patch_oflo - inc MB_ADDR_H - -mb_patch_oflo: - lda MB_ADDR_H - cmp #>done_pt3_irq_handler - bne mb_patch_loop - lda MB_ADDR_L - cmp #