diff --git a/misc/Memory Map.ods b/misc/Memory Map.ods index 04aed86..3013222 100644 Binary files a/misc/Memory Map.ods and b/misc/Memory Map.ods differ diff --git a/roms/f256k/toolbox-00.bin b/roms/f256k/toolbox-00.bin deleted file mode 100644 index cec34f6..0000000 Binary files a/roms/f256k/toolbox-00.bin and /dev/null differ diff --git a/roms/f256k/toolbox-01.bin b/roms/f256k/toolbox-01.bin deleted file mode 100644 index 80831b4..0000000 Binary files a/roms/f256k/toolbox-01.bin and /dev/null differ diff --git a/roms/f256k/toolbox-02.bin b/roms/f256k/toolbox-02.bin deleted file mode 100644 index d619f45..0000000 Binary files a/roms/f256k/toolbox-02.bin and /dev/null differ diff --git a/roms/f256k/toolbox-03.bin b/roms/f256k/toolbox-03.bin deleted file mode 100644 index 4204f45..0000000 Binary files a/roms/f256k/toolbox-03.bin and /dev/null differ diff --git a/roms/f256k/toolbox-04.bin b/roms/f256k/toolbox-04.bin deleted file mode 100644 index 20db7a2..0000000 Binary files a/roms/f256k/toolbox-04.bin and /dev/null differ diff --git a/roms/f256k/toolbox-05.bin b/roms/f256k/toolbox-05.bin deleted file mode 100644 index 67f3874..0000000 Binary files a/roms/f256k/toolbox-05.bin and /dev/null differ diff --git a/roms/f256k/toolbox-06.bin b/roms/f256k/toolbox-06.bin deleted file mode 100644 index 2e27cde..0000000 Binary files a/roms/f256k/toolbox-06.bin and /dev/null differ diff --git a/roms/f256k/toolbox-07.bin b/roms/f256k/toolbox-07.bin deleted file mode 100644 index cd2c586..0000000 Binary files a/roms/f256k/toolbox-07.bin and /dev/null differ diff --git a/roms/f256k/toolbox-08.bin b/roms/f256k/toolbox-08.bin deleted file mode 100644 index 4c048e3..0000000 Binary files a/roms/f256k/toolbox-08.bin and /dev/null differ diff --git a/roms/f256k/toolbox-09.bin b/roms/f256k/toolbox-09.bin deleted file mode 100644 index 0196a6e..0000000 Binary files a/roms/f256k/toolbox-09.bin and /dev/null differ diff --git a/roms/f256k/toolbox-0A.bin b/roms/f256k/toolbox-0A.bin deleted file mode 100644 index 4b80763..0000000 Binary files a/roms/f256k/toolbox-0A.bin and /dev/null differ diff --git a/roms/f256k/toolbox-0B.bin b/roms/f256k/toolbox-0B.bin deleted file mode 100644 index 41a87eb..0000000 Binary files a/roms/f256k/toolbox-0B.bin and /dev/null differ diff --git a/roms/f256k/toolbox-0C.bin b/roms/f256k/toolbox-0C.bin deleted file mode 100644 index 187bf71..0000000 Binary files a/roms/f256k/toolbox-0C.bin and /dev/null differ diff --git a/roms/f256k/toolbox-0D.bin b/roms/f256k/toolbox-0D.bin deleted file mode 100644 index edbf3a0..0000000 Binary files a/roms/f256k/toolbox-0D.bin and /dev/null differ diff --git a/roms/f256k/toolbox-0E.bin b/roms/f256k/toolbox-0E.bin deleted file mode 100644 index cd73497..0000000 Binary files a/roms/f256k/toolbox-0E.bin and /dev/null differ diff --git a/roms/f256k/toolbox-20.bin b/roms/f256k/toolbox-20.bin new file mode 100644 index 0000000..becfba8 Binary files /dev/null and b/roms/f256k/toolbox-20.bin differ diff --git a/roms/f256k/toolbox-21.bin b/roms/f256k/toolbox-21.bin new file mode 100644 index 0000000..3a2fa03 Binary files /dev/null and b/roms/f256k/toolbox-21.bin differ diff --git a/roms/f256k/toolbox-22.bin b/roms/f256k/toolbox-22.bin new file mode 100644 index 0000000..aeaf9d7 Binary files /dev/null and b/roms/f256k/toolbox-22.bin differ diff --git a/roms/f256k/toolbox-23.bin b/roms/f256k/toolbox-23.bin new file mode 100644 index 0000000..fbee9a6 Binary files /dev/null and b/roms/f256k/toolbox-23.bin differ diff --git a/roms/f256k/toolbox-24.bin b/roms/f256k/toolbox-24.bin new file mode 100644 index 0000000..d708e37 Binary files /dev/null and b/roms/f256k/toolbox-24.bin differ diff --git a/roms/f256k/toolbox-25.bin b/roms/f256k/toolbox-25.bin new file mode 100644 index 0000000..34177e5 Binary files /dev/null and b/roms/f256k/toolbox-25.bin differ diff --git a/roms/f256k/toolbox-26.bin b/roms/f256k/toolbox-26.bin new file mode 100644 index 0000000..11f0200 Binary files /dev/null and b/roms/f256k/toolbox-26.bin differ diff --git a/roms/f256k/toolbox-27.bin b/roms/f256k/toolbox-27.bin new file mode 100644 index 0000000..5e0d044 Binary files /dev/null and b/roms/f256k/toolbox-27.bin differ diff --git a/roms/f256k/toolbox-28.bin b/roms/f256k/toolbox-28.bin new file mode 100644 index 0000000..9c98505 Binary files /dev/null and b/roms/f256k/toolbox-28.bin differ diff --git a/roms/f256k/toolbox-29.bin b/roms/f256k/toolbox-29.bin new file mode 100644 index 0000000..376a0c1 Binary files /dev/null and b/roms/f256k/toolbox-29.bin differ diff --git a/roms/f256k/toolbox-2A.bin b/roms/f256k/toolbox-2A.bin new file mode 100644 index 0000000..c82d01e Binary files /dev/null and b/roms/f256k/toolbox-2A.bin differ diff --git a/roms/f256k/toolbox-2B.bin b/roms/f256k/toolbox-2B.bin new file mode 100644 index 0000000..f1c308e Binary files /dev/null and b/roms/f256k/toolbox-2B.bin differ diff --git a/roms/f256k/toolbox-2C.bin b/roms/f256k/toolbox-2C.bin new file mode 100644 index 0000000..cf04955 Binary files /dev/null and b/roms/f256k/toolbox-2C.bin differ diff --git a/roms/f256k/toolbox-2D.bin b/roms/f256k/toolbox-2D.bin new file mode 100644 index 0000000..d6af58c Binary files /dev/null and b/roms/f256k/toolbox-2D.bin differ diff --git a/roms/f256k/toolbox-2E.bin b/roms/f256k/toolbox-2E.bin new file mode 100644 index 0000000..0195545 Binary files /dev/null and b/roms/f256k/toolbox-2E.bin differ diff --git a/roms/f256k/toolbox-2F.bin b/roms/f256k/toolbox-2F.bin new file mode 100644 index 0000000..9f1f161 Binary files /dev/null and b/roms/f256k/toolbox-2F.bin differ diff --git a/roms/f256k/toolbox-30.bin b/roms/f256k/toolbox-30.bin new file mode 100644 index 0000000..767497f Binary files /dev/null and b/roms/f256k/toolbox-30.bin differ diff --git a/roms/f256k/toolbox-0F.bin b/roms/f256k/toolbox-31.bin similarity index 62% rename from roms/f256k/toolbox-0F.bin rename to roms/f256k/toolbox-31.bin index 9a6c02a..2af6a14 100644 Binary files a/roms/f256k/toolbox-0F.bin and b/roms/f256k/toolbox-31.bin differ diff --git a/roms/f256k/toolbox-3F.bin b/roms/f256k/toolbox-3F.bin index 0f8d0c6..493f00d 100644 Binary files a/roms/f256k/toolbox-3F.bin and b/roms/f256k/toolbox-3F.bin differ diff --git a/roms/f256k/toolbox.bin b/roms/f256k/toolbox.bin index 37e4c53..d76b992 100644 Binary files a/roms/f256k/toolbox.bin and b/roms/f256k/toolbox.bin differ diff --git a/roms/f256k/toolbox.csv b/roms/f256k/toolbox.csv index e299297..f654ac5 100644 --- a/roms/f256k/toolbox.csv +++ b/roms/f256k/toolbox.csv @@ -1,17 +1,19 @@ -"00","toolbox-00.bin" -"01","toolbox-01.bin" -"02","toolbox-02.bin" -"03","toolbox-03.bin" -"04","toolbox-04.bin" -"05","toolbox-05.bin" -"06","toolbox-06.bin" -"07","toolbox-07.bin" -"08","toolbox-08.bin" -"09","toolbox-09.bin" -"0A","toolbox-0A.bin" -"0B","toolbox-0B.bin" -"0C","toolbox-0C.bin" -"0D","toolbox-0D.bin" -"0E","toolbox-0E.bin" -"0F","toolbox-0F.bin" +"20","toolbox-20.bin" +"21","toolbox-21.bin" +"22","toolbox-22.bin" +"23","toolbox-23.bin" +"24","toolbox-24.bin" +"25","toolbox-25.bin" +"26","toolbox-26.bin" +"27","toolbox-27.bin" +"28","toolbox-28.bin" +"29","toolbox-29.bin" +"2A","toolbox-2A.bin" +"2B","toolbox-2B.bin" +"2C","toolbox-2C.bin" +"2D","toolbox-2D.bin" +"2E","toolbox-2E.bin" +"2F","toolbox-2F.bin" +"30","toolbox-30.bin" +"31","toolbox-31.bin" "3F","toolbox-3F.bin" diff --git a/src/C256/f256-flash.scm b/src/C256/f256-flash.scm index 1406771..2883579 100644 --- a/src/C256/f256-flash.scm +++ b/src/C256/f256-flash.scm @@ -1,15 +1,20 @@ (define memories '( (memory flash - (address (#xf80000 . #xfdffff)) + (address (#xfc0000 . #xffdfff)) (type ROM) (fill #xff) (section - (jumptable #xf80000) data_init_table data ifar)) + (memory flash-high + (address (#xffe000 . #xfffeff)) + (type ROM) + (fill #xff) + (section jumptable)) + (memory flash-shadow (address (#xffff00 . #xffffff)) (type ROM) @@ -42,12 +47,12 @@ (placement-group bits (section data near))) (memory stackram - (address (#x00c000 . #x00cfff)) + (address (#x00edeb . #xfdeb)) (type RAM) (section stack)) (memory DirectPage - (address (#x00bf00 . #x00bfff)) + (address (#x00fe00 . #x00feff)) (section (registers ztiny))) (block stack (size #x1000)) diff --git a/src/Makefile b/src/Makefile index 37eef00..afa2b91 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,7 +2,7 @@ DEBUGGER=../module/Calypsi-remote-debug/src UNIT := F256K -MEMORY := RAM +MEMORY := ROM # Define OS-dependent variables diff --git a/src/boot.c b/src/boot.c index eb8182a..249ce83 100644 --- a/src/boot.c +++ b/src/boot.c @@ -20,6 +20,7 @@ #include "dev/txt_screen.h" #include "dev/sprites.h" #include "dev/tiles.h" +#include "gabe_reg.h" #include "timers.h" #include "vicky_general.h" #include "rsrc/sprites/boot_sprites.h" @@ -28,6 +29,8 @@ #include #include +#define MAX_BOOT_SRC 5 + const uint32_t boot_record_alignment = 8192; // Number of bytes for boot record alignement const uint32_t boot_rom_location = 0xf80000; // Location to check for a boot record in ROM const uint32_t boot_cart_location = 0xf40000; // Location to check for a boot record in ROM @@ -67,18 +70,12 @@ typedef struct boot_record_s { } boot_record_t, *boot_record_p; /** - * @brief List bootable areas to check, in priority order + * @brief List bootable areas to check, in priority order (without RAM booting) * */ -static enum boot_src_e boot_chain[] = { - BOOT_SRC_RAM, - BOOT_SRC_CARTRIDGE, - BOOT_SRC_SD0, - // BOOT_SRC_SD1, - BOOT_SRC_ROM, -}; - -static bool bootable[10]; +static enum boot_src_e boot_chain[MAX_BOOT_SRC]; +static bool bootable[MAX_BOOT_SRC]; +static short boot_src_cnt = 0; /** * @brief A holder for empty arguments list so we have something to point to when starting a binary file @@ -265,7 +262,7 @@ static void boot_reset_screen() { // txt_set_mode(0, TXT_MODE_TEXT | TXT_MODE_SPRITE); *tvky_mstr_ctrl = (uint16_t)(VKY_MCR_TEXT); - tile_set_assign(0, 0, false); + tile_set_assign(0, 0, 0, false); tile_set_update(0); tile_map_assign(0, 0, 0, 0, 0); @@ -374,13 +371,28 @@ static short sc_to_function(unsigned short scancode) { */ void boot_screen() { enum boot_src_e boot_source = BOOT_SRC_NONE; - boot_record_p boot_record[10]; + boot_record_p boot_record[MAX_BOOT_SRC]; short boot_position = 0; short bootable_count = 0; short i = 0; long jiffies_target = 0; char message[80]; + // Check the DIP switches to see if we should include RAM booting + // Choose the correct boot chain accordingly + + i = 0; + boot_src_cnt = 0; + if ((*GABE_DIP_REG & DIP_BOOT_RAM) == 0) { + boot_chain[0] = BOOT_SRC_RAM; + i = 1; + boot_src_cnt++; + } + boot_chain[i++] = BOOT_SRC_CARTRIDGE; + boot_chain[i++] = BOOT_SRC_SD0; + boot_chain[i++] = BOOT_SRC_ROM; + boot_src_cnt += 3; + // Make sure that ANSI escape codes will be honored chan_ioctrl(0, CON_IOCTRL_ANSI_ON, 0, 0); @@ -403,7 +415,7 @@ void boot_screen() { tile_init(); sprite_init(); - tile_set_assign(0, (uint8_t *)boot_tiles_pixels, false); + tile_set_assign(0, (uint8_t *)boot_tiles_pixels, 8 * (256 + 8), false); tile_set_update(0); tile_map_assign(0, (uint16_t *)boot_tiles_map, 42, 32, 1); @@ -425,7 +437,7 @@ void boot_screen() { printf("Scanning for bootable devices...\n"); - for (short position = 0; position < sizeof(boot_chain) / sizeof(enum boot_src_e); position++) { + for (short position = 0; position < boot_src_cnt; position++) { bootable[position] = false; boot_icon(position, boot_chain[position]); if (is_bootable(boot_chain[position], &boot_record[position])) { @@ -442,18 +454,20 @@ void boot_screen() { // If there is a boot icon specified in the boot record, change to that icon if (boot_record[position] != 0) { - if (boot_record[position]->icon_address != 0) { - sprite_assign(position, (uint8_t *)(boot_record[position]->icon_address), 0, 0); + // TODO: fix cartridge icon issue + + // if (boot_record[position]->icon_address != 0) { + // sprite_assign(position, (uint8_t *)(boot_record[position]->icon_address), 0, 0); - // If there is a CLUT defined for the boot record, switch to use that clut - if (boot_record[position]->clut_address != 0) { - for (i = 0; i < 4 * 256; i++) { - uint8_t * source_clut = (uint8_t *)boot_record[position]->clut_address; - VKY_GR_CLUT_2[i] = source_clut[i]; - } - sprite_clut(position, 2); - } - } + // // If there is a CLUT defined for the boot record, switch to use that clut + // if (boot_record[position]->clut_address != 0) { + // for (i = 0; i < 4 * 256; i++) { + // uint8_t * source_clut = (uint8_t *)boot_record[position]->clut_address; + // VKY_GR_CLUT_2[i] = source_clut[i]; + // } + // sprite_clut(position, 2); + // } + // } } } } @@ -462,7 +476,7 @@ void boot_screen() { if (bootable_count > 1) { printf("\nSelect a boot source:\n\n"); - for (i = 0; i < sizeof(boot_chain) / sizeof(enum boot_src_e); i++) { + for (i = 0; i < boot_src_cnt; i++) { if (bootable[i]) { sprintf(message, "\e[93mF%d\e[37m-%s\n", i+1, boot_source_name(boot_chain[i])); chan_write(0, (uint8_t *)message, strlen(message)); diff --git a/src/dev/sprites.c b/src/dev/sprites.c index 99ed5fe..fa9d416 100644 --- a/src/dev/sprites.c +++ b/src/dev/sprites.c @@ -19,6 +19,8 @@ static t_sprite sprite_shadow[SPRITE_MAX]; +const uint32_t sprite_ram_base = 0x000000; + /** * @brief Update a sprite's hardware registers from the shadow registers * @@ -38,7 +40,13 @@ static void sprite_update(uint8_t sprite) { */ void sprite_assign(uint8_t sprite, const uint8_t * address, uint8_t size, uint8_t layer) { if (sprite < SPRITE_MAX) { - sprite_shadow[sprite].address = (p_far24)address; + + uint8_t * sprite_mem = (uint8_t *)(sprite_ram_base + 32 * 32 * sprite); + for (int i = 0; i < 32 * 32; i++) { + sprite_mem[i] = address[i]; + } + + sprite_shadow[sprite].address = (p_far24)sprite_mem; uint8_t tmp = sprite_shadow[sprite].control & 0x87; // Mask off the size and layer bits tmp |= (size & 0x03) << 5; // Add in the new size tmp |= (layer & 0x03) << 3; // Add in the new layer diff --git a/src/dev/tiles.c b/src/dev/tiles.c index 36d9534..a452daf 100644 --- a/src/dev/tiles.c +++ b/src/dev/tiles.c @@ -7,16 +7,26 @@ static t_tile_set tile_set_shadow[VKY_TILESET_MAX]; static t_tile_map tile_map_shadow[VKY_TILEMAP_MAX]; +const uint32_t tile_set_memory_base = 0x002000; +const uint32_t tile_map_memory_base = 0x003000; + /** * @brief Setup a tile set * * @param set the number of the tile set (0 - 7) * @param address pointer to the bitmap for the tile set + * @param size the number of bytes in the tile set * @param is_square if true, layout of image is square, if false it is 8 or 16 pixels wide */ -void tile_set_assign(uint8_t set, uint8_t * address, bool is_square) { +void tile_set_assign(uint8_t set, uint8_t * address, int size, bool is_square) { if (set <= VKY_TILESET_MAX) { - tile_set_shadow[set].address = (p_far24)address; + + uint8_t * tile_set_ram = (uint8_t *)tile_set_memory_base; + for (int i = 0; i < size; i++) { + tile_set_ram[i] = address[i]; + } + + tile_set_shadow[set].address = (p_far24)tile_set_ram; if (is_square) { tile_set_shadow[set].control = VKY_TILESET_SQUARE; } else { @@ -55,7 +65,13 @@ void tile_init() { */ void tile_map_assign(uint8_t map, uint16_t * address, uint8_t width, uint8_t height, uint8_t size) { if (map <= VKY_TILEMAP_MAX) { - tile_map_shadow[map].address = (p_far24)address; + + uint16_t * tile_map_ram = (uint8_t *)tile_map_memory_base; + for (int i = 0; i < width*height; i++) { + tile_map_ram[i] = address[i]; + } + + tile_map_shadow[map].address = (p_far24)tile_map_ram; tile_map_shadow[map].width = width; tile_map_shadow[map].height = height; if (size == 0) { diff --git a/src/dev/tiles.h b/src/dev/tiles.h index f7f1c05..03c50da 100644 --- a/src/dev/tiles.h +++ b/src/dev/tiles.h @@ -20,9 +20,10 @@ * * @param set the number of the tile set (0 - 7) * @param address pointer to the bitmap for the tile set + * @param size the number of bytes in the tile set * @param is_square if true, layout of image is square, if false it is 8 or 16 pixels wide */ -extern void tile_set_assign(uint8_t set, uint8_t * address, bool is_square); +extern void tile_set_assign(uint8_t set, uint8_t * address, int size, bool is_square); /** * @brief Update the hardware tile set from its shadow diff --git a/src/version.h b/src/version.h index 6f591dc..d8aba33 100644 --- a/src/version.h +++ b/src/version.h @@ -7,6 +7,6 @@ #define VER_MAJOR 1 #define VER_MINOR 0 -#define VER_BUILD 2 +#define VER_BUILD 4 #endif