diff --git a/.gitignore b/.gitignore index 2199dec..c08dd1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ *.swp +*.swo .gitattributes *Output.txt _FileInformation.txt history credentials.h +tags +*.o diff --git a/arduino-lib/Apple2Idiot/A2I_commands.h b/arduino-lib/Apple2Idiot/A2I_commands.h index 3d86bda..c3d1cf4 100644 --- a/arduino-lib/Apple2Idiot/A2I_commands.h +++ b/arduino-lib/Apple2Idiot/A2I_commands.h @@ -6,9 +6,9 @@ // Address offsets -#define RAM_A2I 0 -#define RAM_APPLE 1 -#define SHARED_RAM_START_ADDRESS 2 +//#define RAM_A2I 0 +//#define RAM_APPLE 1 +//#define SHARED_RAM_START_ADDRESS 2 #define MAIN_LOOP_INTERVAL 3 // Unimplemented diff --git a/cc65-lib/apple2idiot.c b/cc65-lib/apple2idiot.c new file mode 100644 index 0000000..c60e9d8 --- /dev/null +++ b/cc65-lib/apple2idiot.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include + +#include "globals.h" +#include "apple2idiot.h" + +#define MAX_STR_LEN 250 + + +unsigned char read_byte(unsigned int address) { + gotoxy(0,2); + //printf("read_data(%u)", address); +} + +unsigned char write_byte(unsigned int address, unsigned char byte_to_write) { + //printf("%u <- %d, [%c]\n", address, byte_to_write, byte_to_write); + POKE(address, byte_to_write); +} + +unsigned char* write_string_to_ram(unsigned int address, char* string_to_send) { + unsigned char i; + unsigned char size = strlen(string_to_send); + gotoxy(0,2); + if (string_to_send[size-1] == '\n') { + string_to_send[size-1] = '\0'; + } + //printf("%u (%s)\n", address, string_to_send); + for (i=0; iwrite_data(ESP_COMMAND_ADDRESS, ACK); // notify Apple IIe we are processing command byte + Serial.println("CHESS() MAKE_MOVE"); String move_string; move_string = a2i->read_string_from_ram(SHARED_RAM_START_ADDRESS); Serial.println("Received move: ["+move_string+"]"); byte result = makeMove(move_string); - int address_counter = a2i->write_data(result, SHARED_RAM_START_ADDRESS); + a2i->write_data(result, ESP_COMMAND_ADDRESS); + int address_counter = a2i->write_string_to_shared_ram(last_ai_move, SHARED_RAM_START_ADDRESS); getBoard(); for (int i=0; i<9; i++) { address_counter = a2i->write_string_to_shared_ram(game_board[i], address_counter + 1); @@ -69,9 +70,12 @@ byte Chess::makeMove(String move_string) { Serial.print("after player move game_status:"); Serial.println(game_status); if (strcmp(game_status, "in_progress") == 0) { - char* ai_move; - ai_move = getAIMove(); - strcat(game_string, ai_move); + //char* ai_move; + //ai_move = getAIMove(); + //strcat(game_string, ai_move); + //last_ai_move = getAIMove(); + strcpy(last_ai_move, getAIMove()); + strcat(game_string, last_ai_move); game_status = getGameStatus(game_string); Serial.print("after AI move game_status:"); Serial.println(game_status); if (strcmp(game_status, "in_progress") == 0) { return STATUS_IN_PROGRESS; } diff --git a/examples/chess/a2i_chess.h b/examples/chess/a2i_chess.h index 53b5ad8..bb691b0 100644 --- a/examples/chess/a2i_chess.h +++ b/examples/chess/a2i_chess.h @@ -24,6 +24,8 @@ class Chess { char game_string[MAX_GAME_SIZE]; // This is probably not enough, but it's fine for development. char game_status[25]; + char last_player_move[5]; // "a2a4" + char last_ai_move[5]; // "8g76" //char game_board[9][20]; char game_board[9][22] = { diff --git a/examples/chess/apple2-cc65/Makefile b/examples/chess/apple2-cc65/Makefile index 7d92ac7..0cff83c 100644 --- a/examples/chess/apple2-cc65/Makefile +++ b/examples/chess/apple2-cc65/Makefile @@ -9,16 +9,17 @@ # Space or comma separated list of cc65 supported target platforms to build for. # Default: c64 (lowercase!) -TARGETS := apple2 +TARGETS := apple2enh +#TARGETS := apple2 # Name of the final, single-file executable. # Default: name of the current dir with target name appended -PROGRAM := weather +PROGRAM := chess # Path(s) to additional libraries required for linking the program # Use only if you don't want to place copies of the libraries in SRCDIR # Default: none -LIBS := +LIBS := # Custom linker configuration file # Use only if you don't want to place it in SRCDIR diff --git a/examples/chess/apple2-cc65/README.md b/examples/chess/apple2-cc65/README.md index 8fb40b6..a4894d0 100644 --- a/examples/chess/apple2-cc65/README.md +++ b/examples/chess/apple2-cc65/README.md @@ -1,9 +1,3 @@ -# Apple2 Internet Weather Client Example - -This is the C code to compile the software that runs on an Apple2 and makes use -of the Apple2idiot card to display the weather for a given city. - - ## How I use this This is how I compile, make a disk and then stage the disk for transfer to my //c using ADTPro. diff --git a/examples/chess/apple2-cc65/adt.bash b/examples/chess/apple2-cc65/adt.bash deleted file mode 100644 index 18a0eda..0000000 --- a/examples/chess/apple2-cc65/adt.bash +++ /dev/null @@ -1,3 +0,0 @@ -java -jar ~/bin/AppleCommander.jar -d ~/bin/ADTPro-2.1.0/disks/dev.dsk weather -java -jar ~/bin/AppleCommander.jar -as ~/bin/ADTPro-2.1.0/disks/dev.dsk weather bin < weather.apple2 -java -jar ~/bin/AppleCommander.jar -l ~/bin/ADTPro-2.1.0/disks/dev.dsk diff --git a/examples/chess/apple2-cc65/apple2/template.dsk b/examples/chess/apple2-cc65/apple2/template.dsk index c408184..bf5b544 100644 Binary files a/examples/chess/apple2-cc65/apple2/template.dsk and b/examples/chess/apple2-cc65/apple2/template.dsk differ diff --git a/examples/chess/apple2-cc65/chess.apple2 b/examples/chess/apple2-cc65/chess.apple2 new file mode 100644 index 0000000..25d1677 Binary files /dev/null and b/examples/chess/apple2-cc65/chess.apple2 differ diff --git a/examples/chess/apple2-cc65/compile.bash b/examples/chess/apple2-cc65/compile.bash deleted file mode 100644 index 416ad6a..0000000 --- a/examples/chess/apple2-cc65/compile.bash +++ /dev/null @@ -1,2 +0,0 @@ -cl65 -t apple2 weather.c -o weather -cp weather.dsk ~/bin/ADTPro-2.1.0/disks/ diff --git a/examples/chess/apple2-cc65/make.bash b/examples/chess/apple2-cc65/make.bash deleted file mode 100644 index c972245..0000000 --- a/examples/chess/apple2-cc65/make.bash +++ /dev/null @@ -1,16 +0,0 @@ -cc65 -g -Oi -t apple2 weather.c -cc65 -g -Oi -t apple2 inputline.c -cc65 -g -Oi -t apple2 menu.c -cc65 -g -Oi -t apple2 screen.c -ca65 -g weather.s -ca65 -g inputline.s -ca65 -g menu.s -ca65 -g screen.s -ld65 -o weather -t apple2 weather.o inputline.o menu.o screen.o apple2.lib - -#cl65 -t apple2 weather.c -o weather -#cl65 -c -Oirs -t apple2 weather.c -o weather -java -jar ~/bin/AppleCommander.jar -d hello.dsk weather -java -jar ~/bin/AppleCommander.jar -as hello.dsk weather bin < weather -java -jar ~/bin/AppleCommander.jar -l hello.dsk -java -jar ~/bin/AppleCommander.jar -as ~/bin/ADTPro-2.1.0/disks/dev.dsk weather bin < weather.apple2 diff --git a/examples/chess/apple2-cc65/mame.bash b/examples/chess/apple2-cc65/mame.bash index 12e5812..af0aa97 100644 --- a/examples/chess/apple2-cc65/mame.bash +++ b/examples/chess/apple2-cc65/mame.bash @@ -1,2 +1,2 @@ # -uimodekey DEL -ui_active -mame apple2e -skip_gameinfo -window -nomax -uimodekey DEL -flop1 weather.dsk +mame apple2e -skip_gameinfo -window -nomax -uimodekey DEL -flop1 chess.dsk diff --git a/examples/chess/apple2-cc65/obj/apple2/apple2idiot.o b/examples/chess/apple2-cc65/obj/apple2/apple2idiot.o index a8871db..e702287 100644 Binary files a/examples/chess/apple2-cc65/obj/apple2/apple2idiot.o and b/examples/chess/apple2-cc65/obj/apple2/apple2idiot.o differ diff --git a/examples/chess/apple2-cc65/obj/apple2/main.d b/examples/chess/apple2-cc65/obj/apple2/main.d index 8a09481..9fd0796 100644 --- a/examples/chess/apple2-cc65/obj/apple2/main.d +++ b/examples/chess/apple2-cc65/obj/apple2/main.d @@ -1,4 +1,4 @@ -obj/apple2/main.o: src/main.c src/globals.h src/menu.h src/apple2idiot.h +obj/apple2/main.o: src/main.c src/globals.h src/menu.h src/apple2idiot.h src/../../chess_commands.h src/../../../../arduino-lib/Apple2Idiot/A2I_commands.h -src/main.c src/globals.h src/menu.h src/apple2idiot.h: +src/main.c src/globals.h src/menu.h src/apple2idiot.h src/../../chess_commands.h src/../../../../arduino-lib/Apple2Idiot/A2I_commands.h: diff --git a/examples/chess/apple2-cc65/obj/apple2/main.o b/examples/chess/apple2-cc65/obj/apple2/main.o index 57c26b1..5b03c1a 100644 Binary files a/examples/chess/apple2-cc65/obj/apple2/main.o and b/examples/chess/apple2-cc65/obj/apple2/main.o differ diff --git a/examples/chess/apple2-cc65/obj/apple2/menu.o b/examples/chess/apple2-cc65/obj/apple2/menu.o index 5064ec8..2023bf1 100644 Binary files a/examples/chess/apple2-cc65/obj/apple2/menu.o and b/examples/chess/apple2-cc65/obj/apple2/menu.o differ diff --git a/examples/chess/apple2-cc65/src/apple2idiot.c b/examples/chess/apple2-cc65/src/apple2idiot.c deleted file mode 100644 index c60e9d8..0000000 --- a/examples/chess/apple2-cc65/src/apple2idiot.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include -#include - -#include "globals.h" -#include "apple2idiot.h" - -#define MAX_STR_LEN 250 - - -unsigned char read_byte(unsigned int address) { - gotoxy(0,2); - //printf("read_data(%u)", address); -} - -unsigned char write_byte(unsigned int address, unsigned char byte_to_write) { - //printf("%u <- %d, [%c]\n", address, byte_to_write, byte_to_write); - POKE(address, byte_to_write); -} - -unsigned char* write_string_to_ram(unsigned int address, char* string_to_send) { - unsigned char i; - unsigned char size = strlen(string_to_send); - gotoxy(0,2); - if (string_to_send[size-1] == '\n') { - string_to_send[size-1] = '\0'; - } - //printf("%u (%s)\n", address, string_to_send); - for (i=0; i \"%c\"", key); @@ -101,4 +332,4 @@ void main(void) } } -} + */ diff --git a/examples/chess/apple2-cc65/src/main.o b/examples/chess/apple2-cc65/src/main.o deleted file mode 100644 index 6f6c6bd..0000000 Binary files a/examples/chess/apple2-cc65/src/main.o and /dev/null differ diff --git a/examples/chess/apple2-cc65/src/menu.c b/examples/chess/apple2-cc65/src/menu.c index b40c70a..24cd80e 100644 --- a/examples/chess/apple2-cc65/src/menu.c +++ b/examples/chess/apple2-cc65/src/menu.c @@ -6,27 +6,17 @@ #include "globals.h" #include "menu.h" -#define MENU_LENGTH 5 -#define MENU_WORD_LENGTH 8 -unsigned char menuEntries[MENU_LENGTH][MENU_WORD_LENGTH] = {"Country", "City", "Fetch", "Display", "Quit"}; - void drawMenuBar() { - static unsigned char i; - static unsigned char x_offset; - - x_offset = 0; - cclearxy(0, 0, SIZE_X); gotoxy(0,0); - for(i = 0; i < MENU_LENGTH; i++){ - //printf("%d, %d, %d\n", i, strlen(menuEntries[i]), x_offset); - revers(1); - gotoxy(x_offset, 0); cputc('1' + i); - revers(0); - cputsxy(x_offset + 1, 0, menuEntries[i]); - x_offset += strlen(menuEntries[i]) + 1; - } - revers(0); + revers(1); printf("W"); + revers(0); printf("ifi Game | "); + revers(1); printf("L"); + revers(0); printf("ocal Game | "); + revers(1); printf("S"); + revers(0); printf("ettings | "); + revers(1); printf("Q"); + revers(0); printf("uit"); } void fancy_hline(unsigned char x, unsigned char y) { diff --git a/examples/chess/apple2-cc65/weather.apple2 b/examples/chess/apple2-cc65/weather.apple2 deleted file mode 100644 index c7502a4..0000000 Binary files a/examples/chess/apple2-cc65/weather.apple2 and /dev/null differ diff --git a/examples/chess/apple2-cc65/weather.dsk b/examples/chess/apple2-cc65/weather.dsk deleted file mode 100644 index cba1d05..0000000 Binary files a/examples/chess/apple2-cc65/weather.dsk and /dev/null differ diff --git a/examples/chess/chess.ino b/examples/chess/chess.ino index 74ad125..0b35ec8 100644 --- a/examples/chess/chess.ino +++ b/examples/chess/chess.ino @@ -116,8 +116,6 @@ void loop() { chess_app.handleCommand(command_byte); a2i.write_data(APPLE_COMMAND_ADDRESS, ACK); //a2i.write_data(ESP_COMMAND_ADDRESS, EOT); // notify Apple IIe we are done processing command byte - //a2i.write_data(APPLE_COMMAND_ADDRESS, ACK); - //a2i.write_data(ESP_COMMAND_ADDRESS, result); // notify Apple IIe we are done processing command byte } } lastMainLoopTime = millis();