more work on creating arrays
This commit is contained in:
1 parent
6928907877
commit
7eada6daa7
2 files changed
+167
-26
No files matched your search
@@ -22,36 +22,48 @@ array_create:
|
||||
lda FOUR6
|
||||
pha
|
||||
|
||||
// Push 0 to mark end of the dimensions
|
||||
|
||||
lda #$00
|
||||
pha
|
||||
|
||||
// Now check if the array dimension is given - if not, assume '10' was specified
|
||||
// Check if the array dimension is given - if not, assume '10' was specified
|
||||
|
||||
bit DIMFLG
|
||||
bmi array_create_fetch_dims
|
||||
|
||||
lda #$0A
|
||||
pha
|
||||
lda #$00
|
||||
pha
|
||||
ldx #$01
|
||||
bne array_create_store_dims // branch always
|
||||
|
||||
array_create_fetch_dims:
|
||||
|
||||
ldx #$00 // counts number of dimensions
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
array_create_fetch_dims_loop:
|
||||
|
||||
inx
|
||||
|
||||
// XXX check if stack has reasonable space free
|
||||
|
||||
// Fetch the dimension, put it on the stack - confirmed with orioginal ROM,
|
||||
// that it also stores dimensions in the reverse order
|
||||
|
||||
jsr fetch_uint8
|
||||
jsr fetch_uint16
|
||||
bcs_16 do_SYNTAX_error
|
||||
|
||||
// XXX we probably need to increment LINNUM first
|
||||
|
||||
lda LINNUM+0
|
||||
pha
|
||||
lda LINNUM+1
|
||||
pha
|
||||
|
||||
// Check if more dimensions are given
|
||||
|
||||
jsr fetch_character_skip_spaces
|
||||
cmp #$2C // ','
|
||||
beq array_create_fetch_dims
|
||||
beq array_create_fetch_dims_loop
|
||||
cmp #$29 // ')'
|
||||
bne_16 do_SYNTAX_error
|
||||
|
||||
@@ -62,40 +74,93 @@ array_create_store_dims:
|
||||
// We got the dimensions, time to alocate memory. Arrays are not declared too often,
|
||||
// it will be easier if we perform the garbage collection now
|
||||
|
||||
phx_trash_a
|
||||
jsr varstr_garbage_collect
|
||||
|
||||
// Create the initial array structure
|
||||
|
||||
// Bytes 0/1 - array name, but we can not fetch it easily now, so skip it
|
||||
// Bytes 2/3 - offset to the next array - our will be the last one, so 0 - but we will set it later
|
||||
// Byte 4 - number of dimensions, determine it
|
||||
// Bytes 5+ - size in each dimension
|
||||
|
||||
// INDEX+2/+3 will be used to calculate number of 'records'
|
||||
// __FAC1+0/+1 will be used to calculate number of elements
|
||||
|
||||
ldy #$01
|
||||
sty INDEX+3
|
||||
sty __FAC1+0
|
||||
dey
|
||||
sty INDEX+4
|
||||
sty __FAC1+1
|
||||
|
||||
ldy #$05
|
||||
!:
|
||||
// Create the initial array structure (format checked by creating arrays with original ROM)
|
||||
|
||||
// Bytes 0/1 - array name, but we can not fetch it easily now, so skip it for now
|
||||
// Bytes 2/3 - offset to the next array, skip it for now too
|
||||
// Byte 4 - number of dimensions
|
||||
// Bytes 5+ - max index in each dimension (big endian!), this will be set in a loop
|
||||
|
||||
ldy #$04
|
||||
pla
|
||||
beq array_create_store_num_dims
|
||||
|
||||
// XXX implement this
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
|
||||
// XXX
|
||||
// XXX: implement this
|
||||
// XXX
|
||||
|
||||
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
|
||||
array_create_store_num_dims:
|
||||
sta (STREND), y
|
||||
|
||||
// .Y contains number of dimensions + 5
|
||||
#endif
|
||||
|
||||
// XXX rework code below
|
||||
iny // .Y - index to store dimension sizes
|
||||
tax // .X - dimensions not sotred yet
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
array_create_store_loop:
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
|
||||
// XXX
|
||||
// XXX: implement this
|
||||
// XXX
|
||||
|
||||
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
|
||||
pla
|
||||
sta (STREND), y
|
||||
sta __FAC1+3
|
||||
iny
|
||||
pla
|
||||
sta (STREND), y
|
||||
sta __FAC1+2
|
||||
iny
|
||||
|
||||
#endif
|
||||
|
||||
jsr helper_array_create_mul
|
||||
|
||||
dex
|
||||
bne array_create_store_loop
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
array_create_store_dims_done:
|
||||
|
||||
// Restore FOUR6, calculate number of bytes needed for storage
|
||||
|
||||
pha
|
||||
sta FOUR6 // XXX do we need to store this value in FOUR6?
|
||||
sta __FAC1+2
|
||||
stx __FAC1+3 // .X is 0 at this point
|
||||
|
||||
jsr helper_array_create_mul
|
||||
|
||||
// XXX check if we have enough memory
|
||||
|
||||
// XXX retrieve and store array name
|
||||
|
||||
// XXX calculate and store offset to the next array
|
||||
|
||||
// XXX clear area
|
||||
|
||||
// XXX adjust STREND
|
||||
|
||||
// XXX adjust offset of the previous array
|
||||
|
||||
jmp do_NOT_IMPLEMENTED_error
|
||||
|
||||
jsr do_NOT_IMPLEMENTED_error
|
||||
Reference in new issue
Block a user