diff --git a/src/adstyle.a b/src/adstyle.a index a48a2fb..1a515da 100644 --- a/src/adstyle.a +++ b/src/adstyle.a @@ -1,3 +1,4 @@ + ; /!\ execution falls through from TraceDOS33c ;------------------------------- ; ADStyle ; Caller has determined that the RWTS in memory @@ -291,4 +292,4 @@ _b4bbexit lda #kSectorSwitchToBuiltinRWTS sta T02S0F + - jmp ReadWithRWTS + ; /!\ execution falls through here to ReadWithRWTS diff --git a/src/crackme.a b/src/crackme.a index 1606f04..38edc1d 100644 --- a/src/crackme.a +++ b/src/crackme.a @@ -1,3 +1,4 @@ + ; /!\ execution falls though from ADStyle ;------------------------------- ; ReadWithRWTS ; This is the main loop. The caller has put an RWTS diff --git a/src/harddisk.a b/src/harddisk.a index e8c32c2..67ccf03 100644 --- a/src/harddisk.a +++ b/src/harddisk.a @@ -4,6 +4,48 @@ HardDirName_e HardDiskName !raw "/IMG0000.DSK" HardDiskName_e +;------------------------------- +; CloseFileOnHardDisk +; close the previously open file on a hard disk, if any +; +; always safe to call (gracefully returns if no file is open) +; does not return any error status because no one cares +; +; in: ProDOS is in memory +; out: all registers and flags clobbered +; ProDOS is in memory +;------------------------------- +!macro CloseFileOnHardDisk { + lda gHardDiskRef + beq + + jsr CloseFile + lda #0 + sta gHardDiskRef ++ +} + +;------------------------------- +; PrintHardDiskImagePath +; print full path of file on hard disk +; +; in: @HardDiskImagePath is populated and has non-zero length +; out: all registers and flags clobbered +;------------------------------- +!macro PrintHardDiskImagePath { + lda HardDiskImagePath + sta @volumelen + ldx #0 +- lda HardDiskImagePath+1, x + ora #$80 + jsr PrintA + inx +@volumelen=*+1 + cpx #$FD ; SMC + bcc - + lda #$8D + jsr PrintA +} + ;------------------------------- ; CreateFileOnHardDisk ; create a new autonumbered image file on the user's selected target, @@ -95,46 +137,5 @@ CreateFileOnHardDisk jsr Create140KFile bcs + sta gHardDiskRef -+ jmp SwapProDOS ; ProDOS in -> out (preserves flags) - -;------------------------------- -; CloseFileOnHardDisk -; close the previously open file on a hard disk, if any -; -; always safe to call (gracefully returns if no file is open) -; does not return any error status because no one cares -; -; in: ProDOS is in memory -; out: all registers and flags clobbered -; ProDOS is in memory -;------------------------------- -!macro CloseFileOnHardDisk { - lda gHardDiskRef - beq + - jsr CloseFile - lda #0 - sta gHardDiskRef + -} - -;------------------------------- -; PrintHardDiskImagePath -; print full path of file on hard disk -; -; in: @HardDiskImagePath is populated and has non-zero length -; out: all registers and flags clobbered -;------------------------------- -!macro PrintHardDiskImagePath { - lda HardDiskImagePath - sta @volumelen - ldx #0 -- lda HardDiskImagePath+1, x - ora #$80 - jsr PrintA - inx -@volumelen=*+1 - cpx #$FD ; SMC - bcc - - lda #$8D - jsr PrintA -} + ; /!\ execution falls through to SwapProDOS diff --git a/src/id/trace.a b/src/id/trace.a index aa2fbca..c19542f 100644 --- a/src/id/trace.a +++ b/src/id/trace.a @@ -30,5 +30,5 @@ Trace ++ pla jsr PrintByID ; unknown disk controller !byte s_canttrace - jmp UseUniversal + ; /!\ execution falls through here to UseUniversal } diff --git a/src/id/trace33.a b/src/id/trace33.a index 1163d4d..83dbba3 100755 --- a/src/id/trace33.a +++ b/src/id/trace33.a @@ -388,5 +388,5 @@ TraceDOS33c ; 2nd-level trace callback is here ; ; good to go ; - jmp ADStyle ; use this RWTS to read the disk + ; /!\ execution falls through to ADStyle } diff --git a/src/memory.a b/src/memory.a index 4f92822..5bbcf79 100755 --- a/src/memory.a +++ b/src/memory.a @@ -20,7 +20,7 @@ ; B200..BFFF - clobbered by DOS boot tracer (RDOS is B200+, DOS 3.x is B600+) ;------------------------------- - + ; /!\ execution falls through from CreateFileOnHardDisk ;------------------------------- ; SwapProDOS ; saves/restores memory used by ProDOS ($BF00..$BFFF) @@ -96,42 +96,6 @@ CopyMemory bne @source rts -;------------------------------- -; ClearTSBuffer -; clear the $1000 byte memory buffer -; used to store the current track's data -; in: none -; out: Z = 1 -; X preserved -; Y = 0 -; all other flags and registers clobbered -;------------------------------- -ClearTSBuffer - lda #BASEPAGE - ldx #$00 - ldy #$10 - ; /!\ execution falls through here - -;------------------------------- -; ClearMemory -; in: A = source address (high) -; X = value to set -; Y = number of pages -; out: Z = 1 -; X preserved -; Y = 0 -; all other flags and registers clobbered -;------------------------------- -ClearMemory - sta @dest+2 -@dest stx $FF00 - inc @dest+1 - bne @dest - inc @dest+2 - dey - bne @dest - rts - ;------------------------------- ; ReorderBuffer - convert data ; buffer between ProDOS and diff --git a/src/memory.clear.a b/src/memory.clear.a new file mode 100644 index 0000000..db77102 --- /dev/null +++ b/src/memory.clear.a @@ -0,0 +1,36 @@ + ; /!\ execution falls through from ChangeTrack +;------------------------------- +; ClearTSBuffer +; clear the $1000 byte memory buffer +; used to store the current track's data +; in: none +; out: Z = 1 +; X preserved +; Y = 0 +; all other flags and registers clobbered +;------------------------------- +ClearTSBuffer + lda #BASEPAGE + ldx #$00 + ldy #$10 + ; /!\ execution falls through here + +;------------------------------- +; ClearMemory +; in: A = source address (high) +; X = value to set +; Y = number of pages +; out: Z = 1 +; X preserved +; Y = 0 +; all other flags and registers clobbered +;------------------------------- +ClearMemory + sta @dest+2 +@dest stx $FF00 + inc @dest+1 + bne @dest + inc @dest+2 + dey + bne @dest + rts diff --git a/src/passport.a b/src/passport.a index 5a4cd53..9fb3591 100755 --- a/src/passport.a +++ b/src/passport.a @@ -46,11 +46,6 @@ Relocatable NonRelocatable !source "apidefs.a" !source "strings/en.a" - !source "id/trace.a" - !source "id/trace33.a" - !source "id/trace32.a" - !source "id/trace8b3.a" - !source "id/trace33p.a" !source "id/dos33.a" !source "id/dos32.a" !source "id/dos32lo.a" @@ -81,27 +76,33 @@ NonRelocatable !source "id/holle.a" !source "id/phoenix.a" !source "id/555.a" + !source "id/trace32.a" + !source "id/trace8b3.a" + !source "id/trace33p.a" + !source "id/trace.a" ; \__ execution falls through + !source "universalstyle.a" ; / + !source "id/trace33.a" ; \__ execution falls through + !source "adstyle.a" ; / + !source "crackme.a" ; / !source "id/inspect0.a" !source "print.a" !source "compare.a" !source "modify.a" - !source "memory.a" !source "sectormap.a" !source "write.a" !source "mli.a" !source "ramdisk.a" - !source "harddisk.a" + !source "harddisk.a" ; \__ execution falls through + !source "memory.a" ; / !source "slots.a" !source "prefs.a" !source "prefs.save.a" !source "keys.a" !source "cffa.a" !source "progress.a" - !source "rwts.a" + !source "rwts.a" ; \__ execution falls through + !source "memory.clear.a" ; / !source "standarddelivery.a" - !source "adstyle.a" - !source "universalstyle.a" - !source "crackme.a" MainMenu jsr Cleanup ; RAM/HD files might be left open after Ctrl-Reset diff --git a/src/print.a b/src/print.a index 35ebe6a..f6dc792 100755 --- a/src/print.a +++ b/src/print.a @@ -142,7 +142,7 @@ PrintByID PrintByte jsr SaveAXY jsr PRBYTE - jmp LoadAXY + bcc LoadAXY ; always branches ;------------------------------- ; PrintA @@ -158,18 +158,16 @@ PrintA jsr SaveAXY jsr COUT ; /!\ execution falls through here - LoadAXY lda tmpa ldx tmpx ldy tmpy - clv - rts - + ; /!\ execution falls through here SaveAXY sta tmpa stx tmpx sty tmpy + clv rts ;------------------------------- @@ -374,229 +372,3 @@ CheckLogKeys sta .endline1+2 sta .endline2+2 rts - -;------------------------------- -; Print Shop style animation -; by Vince `deater` Weaver -; https://github.com/deater/dos33fsprogs/blob/master/graphics/gr/thinking/cracking.s -; SPDX-License-Identifier: MIT - -GBASL = $26 -GBASH = $27 -COL = $E0 -CURRENT_BITMAP = $E1 -BITMAP_PTR = $E2 -XSAVE = $E3 -SAVED_YY = $E3 -YSAVE = $E4 -SAVED_XX = $E4 -ADJUSTED_YY = $E5 -GBASCALC = $F847 ; take Y-coord/2 in A, put address in GBASL/H ( A trashed, C clear) -SETGR = $FB40 ; Init graphics, clear screen, A is $D0 after -WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us - -thinking: - - jsr SETGR ; set lo-res 40x40 mode - ; A=$D0 afterward - - lda #0 - sta COL ; consistent starting color - ; not technically needed - - ;============================= - ;============================= - ; print thinking frame - ;============================= - ;============================= -print_thinking_frame: - - ldx #0 ; reset YY to 0 - stx BITMAP_PTR ; also reset bitmap pointer to 0 - -yloop: - txa ; load YY - jsr GBASCALC ; take Y-coord/2 in A, put address in GBASL/H - - ;======================= - - ldy #0 ; reset XX to 0 -xloop: - - ; this is only jumped to every 8th XX -inc_pointer: - inc BITMAP_PTR - - ; load current bitmap ptr into CURRENT_BITMAP - ; is a don't care if not between 7 and 14 - - stx XSAVE - ldx BITMAP_PTR - lda thinking_data-1-30,X - sta CURRENT_BITMAP - ldx XSAVE - -thinking_xloop: - ; this is called every XX - - stx XSAVE ; save X (YY) - sty YSAVE ; save Y (XX) - - ; if YY <6 or YY > 13 then don't draw bitmap - cpx #6 - bcc do_plot - cpx #13 - bcs do_plot - -handle_bitmap: - ror CURRENT_BITMAP ; rotate next bit from bitmap in - bcs skip_plot ; skip plotting (assume BG is black) - -do_plot: - - lda COL ; set starting color - and #$7 - tay - lda color_lookup,Y ; lookup color in table - - ldy YSAVE ; restore Y (XX) - sta (GBASL),Y - -skip_plot: - ;================================== - ; adjust colors to make boxes - - ; 0000000000000000 - ; 0111111111111110 - ; 0122222222222210 - - ; XX is in Y (currently also in YSAVE) - ; YY is in X (currently also in XSAVE) - - ldx SAVED_YY ; YY - ldy SAVED_XX ; XX - - ; if YY is < 10 do following, otherwise reverse - - txa ; put YY in A (saved bytes later) - cmp #10 - bcc counting_up - -counting_down: - ; now doing the reverse - - lda #19 - sec - sbc SAVED_YY - - ; YY (in A) now going from 10..0 - -counting_up: - sta ADJUSTED_YY - -detect_adjust_dir: - ; if YY is < 10 do following, otherwise reverse - - ; if XX is < 10, check for inc - ; if XX is > 30 check for dex - ; else, no adjust - - cpy #10 ; is XX < 10 - bcc color_adjust_up ; then potentially adjust UP - cpy #30 ; is XX > 30 - bcs color_adjust_down ; then potentially adjust down - bcc color_adjust_none ; else, do nothing - - -color_adjust_up: - - ; if XX < YY then inc color - ; if XX >= YY then do nothing - - cpy ADJUSTED_YY ; compare XX to YY - bcs col_same ; bge do nothing - -col_inc: - inc COL -col_same: - - jmp color_adjust_none - -color_adjust_down: - - lda #39 - sec - sbc ADJUSTED_YY - sta ADJUSTED_YY - - cpy ADJUSTED_YY ; compare XX to YY - - ; if XX > 39-YY then inc color - bcc col_down_same - -col_dec: - dec COL -col_down_same: - - ; fallthrough - -color_adjust_none: - - ;============================ - ; inc XX for next pixel - - iny ; inc XX - - cpy #40 ; if we hit 40, done line - beq done_done - - tya ; if we are multiple of 8 - and #$7 ; then need to increment bitmap ptr - beq inc_pointer - bne thinking_xloop -done_done: - - ;============================================= - ; adjust color for next line - - inc COL - - ;======================= - ; move to next line - - inx - cpx #20 - bne yloop - - ;============================================ - ; done frame, increment color for next round - ;============================================ - - inc COL - - rts - - -;0 1 2 3 3 -;01234567|89012345|67890123|45678901|23456789 -; ** ***| *** | ** * |* * * |* *** -; * * |* * * |* * *| * ** |* * * -; * * |* * * |* * * | * ** |* * -; * ***| ***** |* ** | * * * |* * -; * * *| * * |* * * | * * *|* * ** -; * * |* * * |* * *| * * *|* * * -; ** * |* * * | ** * |* * * |* **** -; 7*5 bytes = 35 bytes - -thinking_data: - !byte $EC,$38,$16,$15,$39 - !byte $22,$45,$91,$34,$45 - !byte $22,$45,$51,$34,$05 - !byte $E2,$7C,$31,$54,$05 - !byte $A2,$44,$51,$94,$65 - !byte $22,$45,$91,$94,$45 - !byte $2C,$45,$16,$15,$79 - -color_lookup: - ; magenta, pink, orange, yellow, lgreen, aqua, mblue, lblue - !byte $33,$BB,$99,$DD,$CC,$EE,$66,$77 diff --git a/src/progress.a b/src/progress.a index e14f648..23f97a5 100644 --- a/src/progress.a +++ b/src/progress.a @@ -37,15 +37,240 @@ ResetProgress lda gMode ror bcc + - jmp thinking + bcs thinking ; always branches IncProgress lda gMode ror - bcs ++ + bcs print_thinking_frame lda #$20 ; display minimal progress indicator progressind sta $FFFF ; SMC inc progressind+1 + rts -++ jmp print_thinking_frame + +;------------------------------- +; Print Shop style animation +; by Vince `deater` Weaver +; https://github.com/deater/dos33fsprogs/blob/master/graphics/gr/thinking/cracking.s +; SPDX-License-Identifier: MIT + +GBASL = $26 +GBASH = $27 +COL = $E0 +CURRENT_BITMAP = $E1 +BITMAP_PTR = $E2 +XSAVE = $E3 +SAVED_YY = $E3 +YSAVE = $E4 +SAVED_XX = $E4 +ADJUSTED_YY = $E5 +GBASCALC = $F847 ; take Y-coord/2 in A, put address in GBASL/H ( A trashed, C clear) +SETGR = $FB40 ; Init graphics, clear screen, A is $D0 after +WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us + +thinking: + + jsr SETGR ; set lo-res 40x40 mode + ; A=$D0 afterward + + lda #0 + sta COL ; consistent starting color + ; not technically needed + + ;============================= + ;============================= + ; print thinking frame + ;============================= + ;============================= +print_thinking_frame: + + ldx #0 ; reset YY to 0 + stx BITMAP_PTR ; also reset bitmap pointer to 0 + +yloop: + txa ; load YY + jsr GBASCALC ; take Y-coord/2 in A, put address in GBASL/H + + ;======================= + + ldy #0 ; reset XX to 0 +xloop: + + ; this is only jumped to every 8th XX +inc_pointer: + inc BITMAP_PTR + + ; load current bitmap ptr into CURRENT_BITMAP + ; is a don't care if not between 7 and 14 + + stx XSAVE + ldx BITMAP_PTR + lda thinking_data-1-30,X + sta CURRENT_BITMAP + ldx XSAVE + +thinking_xloop: + ; this is called every XX + + stx XSAVE ; save X (YY) + sty YSAVE ; save Y (XX) + + ; if YY <6 or YY > 13 then don't draw bitmap + cpx #6 + bcc do_plot + cpx #13 + bcs do_plot + +handle_bitmap: + ror CURRENT_BITMAP ; rotate next bit from bitmap in + bcs skip_plot ; skip plotting (assume BG is black) + +do_plot: + + lda COL ; set starting color + and #$7 + tay + lda color_lookup,Y ; lookup color in table + + ldy YSAVE ; restore Y (XX) + sta (GBASL),Y + +skip_plot: + ;================================== + ; adjust colors to make boxes + + ; 0000000000000000 + ; 0111111111111110 + ; 0122222222222210 + + ; XX is in Y (currently also in YSAVE) + ; YY is in X (currently also in XSAVE) + + ldx SAVED_YY ; YY + ldy SAVED_XX ; XX + + ; if YY is < 10 do following, otherwise reverse + + txa ; put YY in A (saved bytes later) + cmp #10 + bcc counting_up + +counting_down: + ; now doing the reverse + + lda #19 + sec + sbc SAVED_YY + + ; YY (in A) now going from 10..0 + +counting_up: + sta ADJUSTED_YY + +detect_adjust_dir: + ; if YY is < 10 do following, otherwise reverse + + ; if XX is < 10, check for inc + ; if XX is > 30 check for dex + ; else, no adjust + + cpy #10 ; is XX < 10 + bcc color_adjust_up ; then potentially adjust UP + cpy #30 ; is XX > 30 + bcs color_adjust_down ; then potentially adjust down + bcc color_adjust_none ; else, do nothing + + +color_adjust_up: + + ; if XX < YY then inc color + ; if XX >= YY then do nothing + + cpy ADJUSTED_YY ; compare XX to YY + bcs col_same ; bge do nothing + +col_inc: + inc COL +col_same: + + bne color_adjust_none ; always branches + +color_adjust_down: + + lda #39 + sec + sbc ADJUSTED_YY + sta ADJUSTED_YY + + cpy ADJUSTED_YY ; compare XX to YY + + ; if XX > 39-YY then inc color + bcc col_down_same + +col_dec: + dec COL +col_down_same: + + ; fallthrough + +color_adjust_none: + + ;============================ + ; inc XX for next pixel + + iny ; inc XX + + cpy #40 ; if we hit 40, done line + beq done_done + + tya ; if we are multiple of 8 + and #$7 ; then need to increment bitmap ptr + beq inc_pointer + bne thinking_xloop +done_done: + + ;============================================= + ; adjust color for next line + + inc COL + + ;======================= + ; move to next line + + inx + cpx #20 + bne yloop + + ;============================================ + ; done frame, increment color for next round + ;============================================ + + inc COL + + rts + + +;0 1 2 3 3 +;01234567|89012345|67890123|45678901|23456789 +; ** ***| *** | ** * |* * * |* *** +; * * |* * * |* * *| * ** |* * * +; * * |* * * |* * * | * ** |* * +; * ***| ***** |* ** | * * * |* * +; * * *| * * |* * * | * * *|* * ** +; * * |* * * |* * *| * * *|* * * +; ** * |* * * | ** * |* * * |* **** +; 7*5 bytes = 35 bytes + +thinking_data: + !byte $EC,$38,$16,$15,$39 + !byte $22,$45,$91,$34,$45 + !byte $22,$45,$51,$34,$05 + !byte $E2,$7C,$31,$54,$05 + !byte $A2,$44,$51,$94,$65 + !byte $22,$45,$91,$94,$45 + !byte $2C,$45,$16,$15,$79 + +color_lookup: + ; magenta, pink, orange, yellow, lgreen, aqua, mblue, lblue + !byte $33,$BB,$99,$DD,$CC,$EE,$66,$77 diff --git a/src/rwts.a b/src/rwts.a index a69ddcb..f37e919 100755 --- a/src/rwts.a +++ b/src/rwts.a @@ -135,32 +135,6 @@ IgnoreAddressChecksum stx $B98A rts -;------------------------------- -; ChangeTrack -; in: A = new track -;------------------------------- -ChangeTrack - sta @new+1 - jsr WriteTrack -@new lda #$d1 ; modified at runtime - -; note: execution falls through here - -ChangeTrackNW ; "N"o "W"rite - sta gTrack - jmp ClearTSBuffer - -;------------------------------- -; ChangeSector -; in: A = new sector -;------------------------------- -ChangeSector - sta gSector - clc - adc #BASEPAGE - sta gAddress+1 - rts - ;------------------------------- ; WriteTrack ; in: none @@ -232,3 +206,28 @@ FatalWriteError jsr PrintByID + !byte $FD ; SMC jmp TheEnd + +;------------------------------- +; ChangeSector +; in: A = new sector +;------------------------------- +ChangeSector + sta gSector + clc + adc #BASEPAGE + sta gAddress+1 + rts + +;------------------------------- +; ChangeTrack +; in: A = new track +;------------------------------- +ChangeTrack + sta @new+1 + jsr WriteTrack +@new lda #$d1 ; modified at runtime + ; /!\ execution falls through here + +ChangeTrackNW ; "N"o "W"rite + sta gTrack + ; /!\ execution falls through here to ClearTSBuffer diff --git a/src/universalstyle.a b/src/universalstyle.a index 40c6f3d..aa52828 100644 --- a/src/universalstyle.a +++ b/src/universalstyle.a @@ -1,3 +1,4 @@ + ; /!\ execution falls through here from Trace ;------------------------------- ; UseUniversal ; Caller has decided to use the built-in RWTS to read diff --git a/src/wholetrack.a b/src/wholetrack.a index 6caaac9..d09541d 100755 --- a/src/wholetrack.a +++ b/src/wholetrack.a @@ -63,7 +63,7 @@ SkipTrack bpl @print bvc @print ; if we're in 'crack' mode, restart the scan to find the protection code - jmp SetupF7F6SecondRound + bvs SetupF7F6SecondRound ; always branches @print sta + jsr PrintByID