started work on array element location
This commit is contained in:
1 parent
f70fe31e0c
commit
8e2a91cbd6
6 files changed
+186
-32
No files matched your search
@@ -10,15 +10,18 @@ array_create:
|
||||
jsr fetch_variable_name
|
||||
bcs_16 do_SYNTAX_error
|
||||
|
||||
// XXX check if the array already exists
|
||||
// Make sure the array does not exist
|
||||
|
||||
jsr find_array
|
||||
bcc_16 do_REDIMD_ARRAY_error
|
||||
|
||||
// Push variable name and FOUR6 on the stack - fetching dimensions might cause
|
||||
// the to be overwritten by the expression parser
|
||||
|
||||
lda VARNAM+0
|
||||
pha
|
||||
lda VARNAM+1
|
||||
pha
|
||||
lda VARNAM+0
|
||||
pha
|
||||
lda FOUR6
|
||||
pha
|
||||
|
||||
@@ -180,7 +183,7 @@ array_create_store_dims_done:
|
||||
// Restore FOUR6, calculate number of bytes needed for storage
|
||||
|
||||
pla
|
||||
sta FOUR6 // XXX do we need to store this value in FOUR6? is it still needed?
|
||||
sta FOUR6 // needed by variable fetch routine
|
||||
|
||||
sta __FAC1+3
|
||||
stx __FAC1+4 // .X is 0 at this point
|
||||
|
||||
@@ -57,36 +57,8 @@ fetch_variable_find_addr_loop:
|
||||
beq fetch_variable_alocate
|
||||
!:
|
||||
// Compare current variable name with searched one
|
||||
// XXX consider creating optimized version for 46K/50K memory models
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
jsr helper_cmp_varnam
|
||||
#else
|
||||
|
||||
ldy #$00
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
ldx #<VARPNT
|
||||
jsr peek_under_roms
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
lda (VARPNT),y
|
||||
#endif
|
||||
|
||||
cmp VARNAM+0
|
||||
bne fetch_variable_find_addr_next
|
||||
|
||||
iny
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
jsr peek_under_roms
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
lda (VARPNT),y
|
||||
#endif
|
||||
|
||||
cmp VARNAM+1
|
||||
|
||||
#endif
|
||||
|
||||
bne fetch_variable_find_addr_next
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
@@ -5,6 +5,18 @@
|
||||
|
||||
fetch_variable_arr:
|
||||
|
||||
jsr find_array
|
||||
bcc !+
|
||||
|
||||
// Array does not exist - we will have to create one with default parameters
|
||||
|
||||
lda #$00
|
||||
sta VARPNT+1
|
||||
!:
|
||||
// Fetch the 'coordinates'
|
||||
|
||||
// XXX implement this
|
||||
|
||||
// XXX finish the implementation
|
||||
|
||||
jmp do_NOT_IMPLEMENTED_error
|
||||
@@ -0,0 +1,89 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
// Carry set = unable to find array
|
||||
|
||||
|
||||
find_array:
|
||||
|
||||
// Initialize VARPNT with the start of array area
|
||||
|
||||
lda ARYTAB+0
|
||||
sta VARPNT+0
|
||||
lda ARYTAB+1
|
||||
sta VARPNT+1
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
find_array_loop:
|
||||
|
||||
// Check if end of arrays
|
||||
|
||||
lda VARPNT+1
|
||||
cmp STREND+1
|
||||
bne !+
|
||||
lda VARPNT+0
|
||||
cmp STREND+0
|
||||
bne !+
|
||||
|
||||
// End of arrays
|
||||
|
||||
sec
|
||||
rts
|
||||
!:
|
||||
jsr helper_cmp_varnam
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
bne_16 find_array_next
|
||||
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K
|
||||
bne find_array_next
|
||||
#endif
|
||||
|
||||
// Array found
|
||||
|
||||
clc
|
||||
rts
|
||||
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K
|
||||
|
||||
find_array_next:
|
||||
|
||||
// Fetch offset to the next array
|
||||
|
||||
ldy #$03
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
|
||||
ldx #<VARPNT
|
||||
|
||||
jsr peek_under_roms
|
||||
pha
|
||||
dey
|
||||
jsr peek_under_roms
|
||||
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
|
||||
lda (VARPNT),y
|
||||
pha
|
||||
dey
|
||||
lda (VARPNT),y
|
||||
|
||||
#endif
|
||||
|
||||
// Adjust VARPNT to point to the next array
|
||||
|
||||
clc
|
||||
adc VARPNT+0
|
||||
sta VARPNT+0
|
||||
|
||||
pla
|
||||
adc VARPNT+1
|
||||
sta VARPNT+1
|
||||
|
||||
// Next iteration
|
||||
|
||||
bcc find_array_loop // branch always
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
// #LAYOUT# STD * #TAKE-HIGH
|
||||
// #LAYOUT# * BASIC_0 #TAKE-HIGH
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
// This has to go $E000 or above - routines below banks out the main BASIC ROM!
|
||||
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
|
||||
find_array_next:
|
||||
|
||||
// Unmap BASIC lower ROM
|
||||
|
||||
lda #$26
|
||||
sta CPU_R6510
|
||||
|
||||
// Fetch offset to the next array
|
||||
|
||||
ldy #$03
|
||||
lda (VARPNT),y
|
||||
pha
|
||||
dey
|
||||
lda (VARPNT),y
|
||||
|
||||
// Adjust VARPNT to point to the next array
|
||||
|
||||
clc
|
||||
adc VARPNT+0
|
||||
sta VARPNT+0
|
||||
|
||||
pla
|
||||
adc VARPNT+1
|
||||
sta VARPNT+1
|
||||
|
||||
// Restore default memory mapping
|
||||
|
||||
lda #$27
|
||||
sta CPU_R6510
|
||||
|
||||
// Next iteration
|
||||
|
||||
jmp find_array_loop
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * BASIC_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K
|
||||
|
||||
helper_cmp_varnam:
|
||||
|
||||
ldy #$00
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
ldx #<VARPNT
|
||||
jsr peek_under_roms
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
lda (VARPNT),y
|
||||
#endif
|
||||
|
||||
cmp VARNAM+0
|
||||
bne !+
|
||||
|
||||
iny
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
jsr peek_under_roms
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
lda (VARPNT),y
|
||||
#endif
|
||||
|
||||
cmp VARNAM+1
|
||||
!:
|
||||
rts
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user