reworked current array creation code (idea was wrong), compilation fix in Kernal
This commit is contained in:
1 parent
28f6a96ff3
commit
6928907877
2 files changed
+70
-34
No files matched your search
@@ -12,54 +12,90 @@ array_create:
|
|||||||
|
|
||||||
// XXX check if the array already exists
|
// XXX check if the array already exists
|
||||||
|
|
||||||
// It will be easier if we first perform garbage collection (arrays are not declared often)
|
// 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 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
|
||||||
|
|
||||||
|
bit DIMFLG
|
||||||
|
bmi array_create_fetch_dims
|
||||||
|
|
||||||
|
lda #$0A
|
||||||
|
pha
|
||||||
|
bne array_create_store_dims // branch always
|
||||||
|
|
||||||
|
array_create_fetch_dims:
|
||||||
|
|
||||||
|
// 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
|
||||||
|
bcs_16 do_SYNTAX_error
|
||||||
|
pha
|
||||||
|
|
||||||
|
// Check if more dimensions are given
|
||||||
|
|
||||||
|
jsr fetch_character_skip_spaces
|
||||||
|
cmp #$2C // ','
|
||||||
|
beq array_create_fetch_dims
|
||||||
|
cmp #$29 // ')'
|
||||||
|
bne_16 do_SYNTAX_error
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
jsr varstr_garbage_collect
|
jsr varstr_garbage_collect
|
||||||
|
|
||||||
// Now, create the array structure
|
// Create the initial array structure
|
||||||
|
|
||||||
lda STREND+0
|
// Bytes 0/1 - array name, but we can not fetch it easily now, so skip it
|
||||||
sta INDEX+0
|
// Bytes 2/3 - offset to the next array - our will be the last one, so 0 - but we will set it later
|
||||||
lda STREND+1
|
// Byte 4 - number of dimensions, determine it
|
||||||
sta INDEX+1
|
// Bytes 5+ - size in each dimension
|
||||||
|
|
||||||
// XXX check if there is enough distance between INDEX and FRETOP
|
// INDEX+2/+3 will be used to calculate number of 'records'
|
||||||
|
|
||||||
// Store:
|
ldy #$01
|
||||||
// - the array name (2 bytes)
|
sty INDEX+3
|
||||||
// - offset to the next array (2 bytes) - 0 to mark the last one
|
dey
|
||||||
// - initial array dimension - 0
|
sty INDEX+4
|
||||||
|
|
||||||
#if CONFIG_MEMORY_MODEL_60K
|
ldy #$05
|
||||||
|
!:
|
||||||
// XXX: implement this
|
pla
|
||||||
|
beq array_create_store_num_dims
|
||||||
|
|
||||||
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
// XXX implement this
|
||||||
|
|
||||||
ldy #$00
|
|
||||||
lda VARNAM+0
|
|
||||||
sta (STREND), y
|
|
||||||
iny
|
|
||||||
lda VARNAM+1
|
|
||||||
sta (STREND), y
|
|
||||||
iny
|
|
||||||
lda #$00
|
|
||||||
sta (STREND),y
|
|
||||||
iny
|
|
||||||
sta (STREND),y
|
|
||||||
iny
|
|
||||||
sta (STREND),y
|
|
||||||
|
|
||||||
#endif
|
array_create_store_num_dims:
|
||||||
|
|
||||||
//
|
// .Y contains number of dimensions + 5
|
||||||
|
|
||||||
|
// XXX rework code below
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// XXX bit DIMFLG, bmi = use default params
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// XXX
|
|
||||||
|
|
||||||
jsr do_NOT_IMPLEMENTED_error
|
jsr do_NOT_IMPLEMENTED_error
|
||||||
@@ -16,13 +16,13 @@ rs232_count_channels:
|
|||||||
ldy LDTND
|
ldy LDTND
|
||||||
!:
|
!:
|
||||||
dey
|
dey
|
||||||
bmi close_rs232_search_done
|
bmi !+
|
||||||
lda FAT, y
|
lda FAT, y
|
||||||
cmp #$02
|
cmp #$02
|
||||||
bne !-
|
bne !-
|
||||||
inx
|
inx
|
||||||
bpl !- // branch always
|
bpl !- // branch always
|
||||||
|
!:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user