TI$ variable can now be assigned

This commit is contained in:
FeralChild64 committed 2020-07-19 15:33:42 +02:00
1 parent 80e6d126b8
commit 8826394e80
4 files changed
+81 -3

No files matched your search

@@ -5,6 +5,80 @@
assign_variable_TI_string:
// XXX implement
// Evaluate the expression, check if the result is suitable
jmp do_NOT_IMPLEMENTED_error
jsr FRMEVL
lda VALTYP
bpl_16 do_TYPE_MISMATCH_error // branch if not string
lda __FAC1+0
cmp #$06
bne_16 do_ILLEGAL_QUANTITY_error // we need exactly 6-character string
// Initialize new time counter, process all the digits
ldy #$00
sty INDEX+0
sty INDEX+1
sty INDEX+2
// FALLTROUGH
// XXX provide optimized version for memory models 46K/50K
assign_variable_TI_string_loop:
// First fetch the digit
#if CONFIG_MEMORY_MODEL_60K
ldx #<(__FAC1 + 1)
jsr peek_under_roms
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
jsr peek_under_roms_via_FAC1_PLUS_1
#else // CONFIG_MEMORY_MODEL_38K
lda (__FAC1 + 1), y
#endif
jsr convert_PETSCII_to_digit
bcs_16 do_ILLEGAL_QUANTITY_error
tax // move decoded digit to .X
// Strangely, original implementation seems to be very permissive,
// it accepts any digit at any position; for compatibility
// we should better follow this convention
assign_variable_TI_string_loop_digit:
cpx #$00
beq assign_variable_TI_string_loop_next
clc
lda table_TI_lo, y
adc INDEX+0
sta INDEX+0
lda table_TI_mid, y
adc INDEX+1
sta INDEX+1
lda table_TI_hi, y
adc INDEX+2
sta INDEX+2
dex
bpl assign_variable_TI_string_loop_digit // branch always
assign_variable_TI_string_loop_next:
iny
cpy #$06
bne assign_variable_TI_string_loop
// Set the resulting value
ldy INDEX+0
ldx INDEX+1
lda INDEX+2
jmp JSETTIM