Skip to content

Commit

Permalink
Fix libraries for legal
Browse files Browse the repository at this point in the history
  • Loading branch information
pubby committed Dec 9, 2023
1 parent 8f4f9bb commit 90c8f48
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/decompress/string.fab
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ asm fn decompress_string() U
default
tsx
stx &stack
lax &decompress_string_ptr.bank
switch ax
ldx &decompress_string_ptr.bank
switch x
ldy #0
label loop
lda (&decompress_string_ptr.a), y
Expand Down
24 changes: 20 additions & 4 deletions lib/math/base_10.fab
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,22 @@ asm fn to_base_10()
U[]($30,$31,$32,$33,$34,$38,$39,$3A,$3B,$3C)
U[]($40,$41,$42,$43,$44,$48,$49,$4A,$4B,$4C)
label to_65535
lax &base_10_input.b
if __illegal
lax &base_10_input.b
else
lda &base_10_input.b
tax
lsr
lsr // integer divide 1024 (result 0-63)

cpx #$A7 // account for overflow of multiplying 24 from 43,000 ($A7F8) onward,
adc #0 // we can just round it to $A700, and the divide by 1024 is fine...
tay
lax mult_24_table+1, y
if __illegal
lax mult_24_table+1, y
else
lda mult_24_table+1, y
tax
and #$F8
adc &base_10_input.a
txa
Expand All @@ -132,7 +140,11 @@ asm fn to_base_10()
// at this point we have a number 0-65 that we have to times by 24,
// add to original sum, and Mod 1024 to get the remainder 0-999

lax mult_24_table, y
if __illegal
lax mult_24_table, y
else
lda mult_24_table, y
tax
and #$F8
clc
adc &base_10_input.a
Expand Down Expand Up @@ -167,7 +179,11 @@ asm fn to_base_10()
label do_99
lsr
tay
lax shifted_bcd_table, y
if __illegal
lax shifted_bcd_table, y
else
lda shifted_bcd_table, y
tax
rol
and #$0F
sta &base_10_result+0
Expand Down

0 comments on commit 90c8f48

Please sign in to comment.