cic 64dd support

This commit is contained in:
Polprzewodnikowy 2022-05-20 00:31:45 +02:00
parent b055a439a4
commit beb927aef3
7 changed files with 47 additions and 36 deletions

View File

@ -5,7 +5,7 @@ set -e
PACKAGE_FILE_NAME="SC64"
FILES=(
"./fw/ftdi-template.xml"
"./fw/ft232h_config.xml"
"./fw/project/lcmxo2/impl1/sc64_impl1.bit"
"./fw/project/lcmxo2/impl1/sc64_impl1.jed"
"./sw/bootloader/build/bootloader.bin"

View File

@ -34,7 +34,6 @@ static const vi_regs_t vi_config[] = {{
VI_CR_PIXEL_ADVANCE_0 |
VI_CR_ANTIALIAS_1 |
VI_CR_ANTIALIAS_0 |
VI_CR_GAMMA_ON |
VI_CR_TYPE_32
),
.H_WIDTH = SCREEN_WIDTH,
@ -55,7 +54,6 @@ static const vi_regs_t vi_config[] = {{
VI_CR_PIXEL_ADVANCE_0 |
VI_CR_ANTIALIAS_1 |
VI_CR_ANTIALIAS_0 |
VI_CR_GAMMA_ON |
VI_CR_TYPE_32
),
.H_WIDTH = SCREEN_WIDTH,

View File

@ -1,3 +1,4 @@
#include "error.h"
#include "exception.h"
#include "io.h"
#include "sc64.h"
@ -8,6 +9,11 @@ void init (void) {
si_io_write((io32_t *) (&PIFRAM[0x3C]), pifram | 0x08);
exception_install();
if (!sc64_check_presence()) {
error_display("SC64 hardware not detected");
}
exception_enable_watchdog();
exception_enable_interrupts();

View File

@ -50,7 +50,6 @@ void sc64_get_info (sc64_info_t *info) {
}
void sc64_init (void) {
while (!sc64_check_presence());
sc64_change_config(CFG_ID_BOOTLOADER_SWITCH, false);
}

View File

@ -5,27 +5,30 @@ from PIL import Image
if (len(sys.argv) != 3):
print(f"Usage: python {sys.argv[0]} input_path output_path")
exit(-1)
if __name__ == "__main__":
if (len(sys.argv) != 3):
print(f"Usage: python {sys.argv[0]} input_path output_path")
sys.exit(1)
asset_input = sys.argv[1]
asset_output = sys.argv[2]
asset_input = sys.argv[1]
asset_output = sys.argv[2]
source_asset = None
final_asset = None
source_asset = None
final_asset = None
try:
source_asset = Image.open(asset_input)
converted_asset = source_asset.convert("RGBA")
final_asset = open(asset_output, "wb")
final_asset.write(converted_asset.tobytes())
except FileNotFoundError:
print(f"Couldn't open file \"{asset_input}\"")
except Exception as e:
print(e)
finally:
if (source_asset):
source_asset.close()
if (final_asset):
final_asset.close()
try:
source_asset = Image.open(asset_input)
converted_asset = source_asset.convert("RGBA")
final_asset = open(asset_output, "wb")
final_asset.write(converted_asset.tobytes())
except FileNotFoundError:
print(f"Couldn't open file \"{asset_input}\"")
sys.exit(2)
except Exception as e:
print(e)
sys.exit(3)
finally:
if (source_asset):
source_asset.close()
if (final_asset):
final_asset.close()

View File

@ -12,6 +12,7 @@ typedef enum {
static volatile bool cic_enabled = false;
static volatile bool cic_detect_enabled;
static volatile uint8_t cic_next_rd;
static volatile uint8_t cic_next_wr;
@ -54,6 +55,12 @@ static void cic_irq_clk_falling (void) {
static void cic_irq_clk_rising (void) {
hw_gpio_set(GPIO_ID_N64_CIC_DQ);
if (cic_detect_enabled) {
cic_detect_enabled = false;
if (!hw_gpio_get(GPIO_ID_N64_CIC_DQ)) {
cic_enabled = false;
}
}
}
static uint8_t cic_read (void) {
@ -67,6 +74,10 @@ static void cic_write (uint8_t bit) {
task_yield();
}
static void cic_start_detect (void) {
cic_detect_enabled = cic_dd_mode;
}
static uint8_t cic_read_nibble (void) {
uint8_t data = 0;
for (int i = 0; i < 4; i++) {
@ -97,17 +108,11 @@ static void cic_encode_round (uint8_t index) {
}
static void cic_write_id (cic_region_t region) {
uint8_t id = 0x01;
if (cic_dd_mode) {
id |= 0x08;
}
if (region == REGION_PAL) {
id |= 0x04;
}
cic_write_nibble(id);
cic_start_detect();
cic_write(cic_dd_mode ? 1 : 0);
cic_write(region == REGION_PAL ? 1 : 0);
cic_write(0);
cic_write(1);
}
static void cic_write_id_failed (void) {