small code reorganization for arrays support

This commit is contained in:
FeralChild64 committed 2020-07-26 18:06:01 +02:00
1 parent 7eada6daa7
commit 07bbc21e50
6 files changed
+101 -19

No files matched your search

@@ -0,0 +1,12 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * BASIC_0 #TAKE
// #LAYOUT# * * #IGNORE
check_stack_space:
tsx
cpx #$60 // XXX is this a safe threshold?
bcc_16 do_FORMULA_TOO_COMPLEX_error
rts
+1 -3
View File
@@ -323,9 +323,7 @@ FRMEVL_push_operator_address:
// Check if there is enough stack space; this could not have been done earlier,
// as this is the place where unary operator support calls
tsx
cpx #$60 // XXX is this a safe threshold?
bcc_16 do_FORMULA_TOO_COMPLEX_error
jsr check_stack_space
// Push the operator address to stack, in a form
// suitable for RTS
+83 -11
View File
@@ -44,15 +44,26 @@ array_create_fetch_dims_loop:
inx
// XXX check if stack has reasonable space free
// Check if the 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 check_stack_space
// Fetch the dimension, increment it by 1, and put it on the stack;
// confirmed with original ROM, that it also stores dimensions in the reverse order
jsr fetch_uint16
bcs_16 do_SYNTAX_error
// XXX we probably need to increment LINNUM first
#if !HAS_OPCODES_65CE02
inc LINNUM+0
bne !+
inc LINNUM+1
!:
#else
inw LINNUM
#endif
beq_16 do_OUT_OF_MEMORY_error
lda LINNUM+0
pha
@@ -144,7 +155,7 @@ 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 FOUR6 // XXX do we need to store this value in FOUR6? is it still needed?
sta __FAC1+2
stx __FAC1+3 // .X is 0 at this point
@@ -152,15 +163,76 @@ array_create_store_dims_done:
// XXX check if we have enough memory
// XXX retrieve and store array name
// Retrieve and store array name
// XXX calculate and store offset to the next array
ldy #$00
// XXX clear area
#if CONFIG_MEMORY_MODEL_60K
// XXX
// XXX: implement this
// XXX
// XXX adjust STREND
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
// XXX adjust offset of the previous array
pla
sta (STREND), y
iny
pla
sta (STREND), y
#endif
// Calculate and store offset to the next array
lda #$02
jsr helper_INDEX_up_A
#if CONFIG_MEMORY_MODEL_60K
// XXX
// XXX: implement this
// XXX
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
// XXX
// XXX: implement this
// XXX
#else // CONFIG_MEMORY_MODEL_38K
ldy #$04
lda (STREND), y
#endif
asl
jsr helper_INDEX_up_A
#if CONFIG_MEMORY_MODEL_60K
// XXX
// XXX: implement this
// XXX
#else // CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
ldy #$02
lda INDEX+0
sta (STREND), y
iny
lda INDEX+1
sta (STREND), y
#endif
// Clear newly alocated area
// XXX implement this
// Adjust STREND
// XXX implement this
jmp do_NOT_IMPLEMENTED_error
@@ -54,14 +54,14 @@ helper_array_create_mul_error:
helper_array_create_mul_success:
lda INDEX+0
sta __FAC+0
sta __FAC1+0
lda INDEX+1
sta __FAC+1
sta __FAC1+1
plx_trash_a
rts
helper_array_create_mul_add:
helper_array_create_mul_8x8_add:
jsr mul_FAC2_FAC1_8x8
@@ -3,7 +3,7 @@
// #LAYOUT# * * #IGNORE
//
// Helper routine, used by garbage collector and string concatenation
// Helper routine, used in several places
//
#if CONFIG_MEMORY_MODEL_38K || CONFIG_MEMORY_MODEL_60K
@@ -5,7 +5,7 @@
// This has to go $E000 or above - it can be used by routines which bank out the main BASIC ROM!
//
// Helper routine, used by garbage collector and string concatenation
// Helper routine, used in several places
//
#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K