begin implementing BASIC interprettor.

This commit is contained in:
Paul Gardner-Stephen committed 2019-04-22 15:36:00 +09:30
1 parent 2f09f2c9a3
commit 97eb5acb31
8 files changed
+132 -8

No files matched your search

+15 -5
View File
@@ -7,11 +7,21 @@ src/preprocess: src/preprocess.c Makefile
gcc -g -Wall -o src/preprocess src/preprocess.c
newkern: c64/kernal/OUT.BIN
cat e000-e4d2 c64/kernal/OUT.BIN >newkern
newrom: c64/kernal/OUT.BIN c64/basic/OUT.BIN
cat c64/basic/OUT.BIN c64/kernal/OUT.BIN >newrom
newkern: newrom Makefile
dd if=newrom bs=8192 count=1 skip=1 of=newkern
newbasic: newrom Makefile
dd if=newrom bs=8192 count=1 skip=0 of=newbasic
c64/kernal/OUT.BIN: src/preprocess c64/kernal/*.s
src/preprocess -d c64/kernal
src/preprocess -d c64/kernal -l e4d3 -h ffff
test: newkern
x64 -kernal newkern -remotemonitor
c64/basic/OUT.BIN: src/preprocess c64/basic/*.s
src/preprocess -d c64/basic -l a000 -h e4d2
test: newkern newbasic
x64 -kernal newkern -basic newbasic -remotemonitor
+77
View File
@@ -0,0 +1,77 @@
; Names of ZP and low memory locations
; (Only those of relevance for the KERNAL)
; (And only those for now that we feel the need to implement initially)
; (https://www.c64-wiki.com/wiki/Zeropage)
.alias TXTTAB $2B
.alias IOSTATUS $90
; Keys down clears bits. STOP=bit 7, C= bit 6, SPACE bit 4, CTRL bit 2
.alias BUCKYSTATUS $91
.alias load_or_verify_flag $93
.alias current_file_num $98
.alias input_device_number $99
; bit 6 = error messages, bit 7 = control messages
.alias kernal_message_control_flags $9d
.alias jiffy_clock_24bits $a0
.alias cassette_buffer_bytes_used $A6
.alias load_or_scroll_temp_pointer $AC
;; We also use the following for temp colour pointer when scrolling
.alias load_save_verify_end_address $AE
.alias cassette_buffer_ptr $B2
.alias current_filename_length $B7
.alias current_logical_filenum $B8
.alias current_secondary_address $B9
.alias current_device_number $BA
.alias current_filename_ptr $BB
.alias load_save_start_ptr $C1
.alias load_save_end_ptr $C3
.alias last_key_matrix_position $C5
.alias keys_in_key_buffer $C6
.alias reverse_video_flag $C7
.alias end_of_input_line $C8
.alias start_of_keyboard_input $C9
.alias current_key_index_entry $CB
.alias cursor_blink_disable $CC
.alias cursor_blink_countdown $CD
.alias cursor_saved_character $CE
.alias cursor_is_visible $CF
.alias keyboard_input_ready $D0
.alias current_screen_line_ptr $D1
.alias current_screen_x $D3
.alias quote_mode_flag $D4
.alias logical_line_length $D5
.alias current_screen_y $D6
.alias last_printed_character_ascii $D7
.alias insert_mode $D8
; Bits 0 -3 = bits 8-11 of screen line address
; Bit 7 = line spans multiple physical lines
.alias screen_line_link_table $D9
.alias current_screen_line_colour_ptr $F3
.alias keyboard_decoding_table_ptr $F5
.alias rs232_rx_buffer_ptr $F7
.alias rs232_tx_buffer_ptr $F9
; "Compute's Mapping the 64" book
.alias keyboard_buffer $0277
.alias MEMSTR $0281
.alias MEMSIZ $0283 ; NOTE: Mapping the 64 erroniously has the hex as $282, while the DEC is correct
.alias text_colour $0286 ; p55
.alias colour_under_cursor $0287 ; p56
.alias HIBASE $0288 ; p56 (high byte of start of screen)
.alias key_buffer_size $0289 ; p57
;; 0 = cursor keys, insert, delete and space repeat, but nothing else
;; 128 = all keys repeat
;; 64 = no keys repeat
.alias key_repeat_flags $028A ; p58
;; https://www.c64-wiki.com/wiki/Page_2
.alias key_repeat_counter $028B
.alias key_first_repeat_delay $028C
;; bit 0 = shift, 1 = Vendor Key, 2 = Control
.alias key_bucky_state $028D
.alias key_last_bucky_state $028E
.alias keyboard_decoding_ptr $028F
.alias enable_case_switch $0291
.alias screen_scroll_disable $0292
.alias pal_or_ntsc $02A6
+3
View File
@@ -0,0 +1,3 @@
;; Compute's Mapping the C64 p88
.word basic_cold_start
+2
View File
@@ -0,0 +1,2 @@
;; Compute's Mapping the C64 p88
.word basic_warm_start
+6
View File
@@ -0,0 +1,6 @@
;; Compute's Mapping the 64, p89
;; 8 character name
;; MEGABAS2 = "MEGA BASIC 2"
.byte $4D,$45,$47,$41,$42,$41,$53,$32
+11
View File
@@ -0,0 +1,11 @@
;; BASIC Cold start entry point
;; Compute's Mapping the 64 p211
basic_cold_start:
;; Setup BASIC vectors at $0300
;; Initialise interpretor
;; Print start up message
;; jump into warm start loop
jmp basic_warm_start
+6
View File
@@ -0,0 +1,6 @@
;; Clear screen etc, show READY prompt.
basic_warm_start:
* inc $d020
jmp -
+12 -3
View File
@@ -61,7 +61,7 @@ int dump_file(FILE *out,const char *name)
void usage(void)
{
fprintf(stderr,"usage: preprocess [-d <directory>]\n");
fprintf(stderr,"usage: preprocess [-d <directory>] [-l <start/low address>] [-h <end/high address>]\n");
}
@@ -72,14 +72,19 @@ int main(int argc,char **argv)
DIR *d=NULL;
char *directory=".";
struct dirent *de=NULL;
int start_address=0xe4d3;
int end_address=0xffff+1;
do {
int opt;
while ((opt=getopt(argc,argv,"d:")) != -1) {
while ((opt=getopt(argc,argv,"d:l:h:")) != -1) {
switch(opt) {
case 'd': directory=optarg; break;
case 'l': start_address=strtol(optarg,NULL,16); break;
case 'h': end_address=strtol(optarg,NULL,16)+1; break;
default:
usage();
exit(-1);
@@ -192,7 +197,7 @@ int main(int argc,char **argv)
// of some routines to be at fixed addresses.
// Start at beginning of actual kernal data
int address=0xe4d3;
int address=start_address;
char filename[8192];
snprintf(filename,8192,"%s/combined.s",directory);
@@ -265,6 +270,10 @@ int main(int argc,char **argv)
address+=source_files[biggest].size;
}
}
fprintf(out,"\t.checkpc $%04x\n\t.advance $%04x,$00\n",
end_address,end_address);
fclose(out);
if (retVal) break;