From 800361b27f87e6552fe47d1a7bb77dd7d42a0af3 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 22 Jul 2020 20:16:25 +0200 Subject: [PATCH] some more work towards arrays --- src/aliases/,aliases_ram_lowmem.s | 2 +- src/basic/basic_commands/cmd__unimplemented.s | 2 - src/basic/basic_commands/cmd_dim.s | 6 +++ src/basic/basic_commands/cmd_let.s | 6 +++ src/basic/engine_variables/array_create.s | 13 +++++++ .../engine_variables/fetch_variable_name.s | 39 +++++++++++++++---- 6 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 src/basic/basic_commands/cmd_dim.s create mode 100644 src/basic/basic_commands/cmd_let.s diff --git a/src/aliases/,aliases_ram_lowmem.s b/src/aliases/,aliases_ram_lowmem.s index f0f4438a..ef37b7ac 100644 --- a/src/aliases/,aliases_ram_lowmem.s +++ b/src/aliases/,aliases_ram_lowmem.s @@ -53,7 +53,7 @@ .label OPMASK = $4D // -- NOT IMPLEMENTED -- .label DEFPNT = $4E // $4E-$4F -- NOT IMPLEMENTED -- .label DSCPNT = $50 // $50-$52 temporary area fro string handling, [!] our usage might differ - .label FOUR6 = $53 // -- NOT IMPLEMENTED -- + .label FOUR6 = $53 // size of variable content (float = 5, integer = 2, string descriptor = 3) .label JMPER = $54 // $54-$56 -- NOT IMPLEMENTED -- .label TEMPF1 = $57 // $57-$5B BASIC numeric work area .label TEMPF2 = $5C // $5C-$60 BASIC numeric work area diff --git a/src/basic/basic_commands/cmd__unimplemented.s b/src/basic/basic_commands/cmd__unimplemented.s index ffa3d866..18c9fb1c 100644 --- a/src/basic/basic_commands/cmd__unimplemented.s +++ b/src/basic/basic_commands/cmd__unimplemented.s @@ -19,8 +19,6 @@ cmd_inputhash: nop cmd_input: nop -cmd_dim: - nop cmd_read: nop cmd_if: diff --git a/src/basic/basic_commands/cmd_dim.s b/src/basic/basic_commands/cmd_dim.s new file mode 100644 index 00000000..cccb47e2 --- /dev/null +++ b/src/basic/basic_commands/cmd_dim.s @@ -0,0 +1,6 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + + +// PLACEHOLDER for completeness - jumptable contains direct address diff --git a/src/basic/basic_commands/cmd_let.s b/src/basic/basic_commands/cmd_let.s new file mode 100644 index 00000000..cccb47e2 --- /dev/null +++ b/src/basic/basic_commands/cmd_let.s @@ -0,0 +1,6 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + + +// PLACEHOLDER for completeness - jumptable contains direct address diff --git a/src/basic/engine_variables/array_create.s b/src/basic/engine_variables/array_create.s index 159d9cc1..d63dd62b 100644 --- a/src/basic/engine_variables/array_create.s +++ b/src/basic/engine_variables/array_create.s @@ -5,6 +5,19 @@ array_create: + // First retrieve array name + + jsr fetch_variable_name + bcs_16 do_SYNTAX_error + + // It will be easier if we first perform garbage collecion (arrays are not declared often) + + jsr varstr_garbage_collect + + // XXX bit DIMFLG, bmi = use default params + + + // XXX jsr do_NOT_IMPLEMENTED_error diff --git a/src/basic/engine_variables/fetch_variable_name.s b/src/basic/engine_variables/fetch_variable_name.s index 5fe50075..74e0dbd5 100644 --- a/src/basic/engine_variables/fetch_variable_name.s +++ b/src/basic/engine_variables/fetch_variable_name.s @@ -4,7 +4,7 @@ // // Carry set = failure, not recognized variable name -// +// sets FOUR6 and DIMFLG ($80 for array, $00 for regular variable) fetch_variable_name: @@ -61,6 +61,9 @@ fetch_variable_check_type: fetch_variable_type_float: + lda #$05 + sta FOUR6 + #if !HAS_OPCODES_65CE02 jsr unconsume_character #else @@ -71,19 +74,25 @@ fetch_variable_type_float: fetch_variable_type_integer: + ldy #$02 + + lda #$02 + sta FOUR6 + lda VARNAM+0 ora #$80 sta VARNAM+0 lda #$00 - skip_2_bytes_trash_nvz - - // FALLTROUGH + beq !+ // branch always fetch_variable_type_string: + ldy #$03 lda #$80 +!: sta VALTYP + sty FOUR6 lda VARNAM+1 ora #$80 @@ -93,10 +102,24 @@ fetch_variable_type_string: fetch_variable_name_check_array: - // XXX add check for array + jsr fetch_character_skip_spaces + cmp #$28 // '(' + beq !+ + + // This is not an array + +#if !HAS_OPCODES_65CE02 + jsr unconsume_character +#else + dew TXTPTR +#endif + lda #$00 + skip_2_bytes_trash_nvz +!: + // This is an array + + lda #$80 + sta DIMFLG - - - clc rts