added fetching TI$ variable, does not fully work yet

This commit is contained in:
FeralChild64 committed 2020-07-18 23:09:07 +02:00
1 parent 080ea5dab5
commit cd44ba2358
10 files changed
+196 -36

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Table to TI$ special variable support
//
table_TI_hi:
.byte $36 // 10 hours = 3600000 ticks
.byte $05 // 1 hour = 360000 ticks
.byte $00 // 10 minutes = 30000 ticks
.byte $00 // 1 minute = 3000 ticks
.byte $00 // 10 seconds = 500 ticks
.byte $00 // 1 second = 50 ticks
+16
View File
@@ -0,0 +1,16 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Table to TI$ special variable support
//
table_TI_lo:
.byte $80 // 10 hours = 3600000 ticks
.byte $40 // 1 hour = 360000 ticks
.byte $30 // 10 minutes = 30000 ticks
.byte $B8 // 1 minute = 3000 ticks
.byte $F4 // 10 seconds = 500 ticks
.byte $32 // 1 second = 50 ticks
+16
View File
@@ -0,0 +1,16 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Table to TI$ special variable support
//
table_TI_mid:
.byte $EE // 10 hours = 3600000 ticks
.byte $7E // 1 hour = 360000 ticks
.byte $75 // 10 minutes = 30000 ticks
.byte $0B // 1 minute = 3000 ticks
.byte $01 // 10 seconds = 500 ticks
.byte $00 // 1 second = 50 ticks
-30
View File
@@ -134,38 +134,8 @@ cmd_let_assign_string:
// Copy the string descriptor to DSCPNT
#if CONFIG_MEMORY_MODEL_60K
ldx #<VARPNT
ldy #$00
jsr peek_under_roms
sta DSCPNT+0
iny
jsr peek_under_roms
sta DSCPNT+1
iny
jsr peek_under_roms
sta DSCPNT+2
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
jsr helper_let_strdesccpy
#else // CONFIG_MEMORY_MODEL_38K
ldy #$00
lda (VARPNT), y
sta DSCPNT+0
iny
lda (VARPNT), y
sta DSCPNT+1
iny
lda (VARPNT), y
sta DSCPNT+2
#endif
// First special case - check if the new string has size 0
lda __FAC1+0
@@ -0,0 +1,26 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Helper routine to copy string descriptor, for LET command and TI$ variable support
//
#if CONFIG_MEMORY_MODEL_38K
helper_let_strdesccpy:
ldy #$00
lda (VARPNT), y
sta DSCPNT+0
iny
lda (VARPNT), y
sta DSCPNT+1
iny
lda (VARPNT), y
sta DSCPNT+2
rts
#endif
@@ -5,7 +5,7 @@
// This has to go $E000 or above - routines below banks out the main BASIC ROM!
//
// Helper routine to copy string descriptor, for LET command
// Helper routine to copy string descriptor, for LET command and TI$ variable support
//
@@ -0,0 +1,28 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Helper routine to copy string descriptor, for LET command and TI$ variable support
//
#if CONFIG_MEMORY_MODEL_60K
helper_let_strdesccpy:
ldx #<VARPNT
ldy #$00
jsr peek_under_roms
sta DSCPNT+0
iny
jsr peek_under_roms
sta DSCPNT+1
iny
jsr peek_under_roms
sta DSCPNT+2
rts
#endif
+9 -3
View File
@@ -9,12 +9,12 @@
fetch_variable:
// Fetch variable name
// Set default second character and variable type
lda #$00
sta VARNAM+1
// Fetch the first character
// Fetch the first character of variable name
jsr fetch_character_skip_spaces
jsr is_AZ
@@ -79,10 +79,16 @@ fetch_variable_type_integer:
ora #$80
sta VARNAM+0
lda #$00
skip_2_bytes_trash_nvz
// FALLTROUGH
fetch_variable_type_string:
lda #$80
sta VALTYP
lda VARNAM+1
ora #$80
sta VARNAM+1
@@ -172,7 +178,7 @@ fetch_variable_find_addr_loop:
fetch_variable_adjust_VARPNT:
// Adjust VARPNT to point just after variable name (XXX is it needed?) and quit
// Adjust VARPNT to point just after variable name and quit
#if !HAS_OPCODES_65CE02
+84 -2
View File
@@ -3,8 +3,90 @@
// #LAYOUT# * * #IGNORE
// XXX test this
fetch_variable_TI_string:
// XXX implement this
// Alocate memory for 6-byte temporary string, copy the string descriptor
jmp do_NOT_IMPLEMENTED_error
lda #$06
jsr tmpstr_alloc
jsr helper_let_strdesccpy
// Fetch the time in a safe way, store it in temporary area
jsr JRDTIM
sty INDEX+0
stx INDEX+1
sta INDEX+2
// Now calculate the digits, starting from the most important one
#if CONFIG_MEMORY_MODEL_60K
ldx #<DSCPNT+1
#endif
ldy #$00
// FALLTROUGH
fetch_variable_TI_string_loop:
// Set the initial digit value ('0')
lda #$30
sta INDEX+3
// Compare the counter with value from table
!:
lda INDEX+2
cmp table_TI_hi, y
bcc fetch_variable_TI_string_got_digit
lda INDEX+1
cmp table_TI_mid, y
bcc fetch_variable_TI_string_got_digit
lda INDEX+0
cmp table_TI_lo, y
bcc fetch_variable_TI_string_got_digit
// Increment digit and subtract the table value from the counter
inc INDEX+3
sec
lda INDEX+0
sbc table_TI_lo, y
sta INDEX+0
lda INDEX+1
sbc table_TI_mid, y
sta INDEX+1
lda INDEX+2
sbc table_TI_hi, y
sta INDEX+2
bcs !- // branch always
fetch_variable_TI_string_got_digit:
// Copy digit to the string
lda INDEX+3
#if CONFIG_MEMORY_MODEL_60K
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_50K || CONFIG_MEMORY_MODEL_60K
sta (DSCPNT+1), y
#endif
// Next iteration
iny
cpy #$06
bne fetch_variable_TI_string_loop
// Return success
clc
rts