Skip to content

Instantly share code, notes, and snippets.

@fu-sen
Last active April 19, 2025 02:37
Show Gist options
  • Save fu-sen/21400660612ad674f660b056fb07ece3 to your computer and use it in GitHub Desktop.
Save fu-sen/21400660612ad674f660b056fb07ece3 to your computer and use it in GitHub Desktop.
// Change to font #A0-#DF | C language for IchigoJam (c4ij, IchigoJam BASIC 1.3.2b13+)
// Original https://github.com/IchigoJam/c4ij/blob/master/src/main-exkbd.c
// Copyright (c) 2019 Taisuke Fukuno / BALLOON | FU-SEN
// The MIT License (MIT) - https://mit.balloon.net.eu.org/#2019
#include <std15.h>
__attribute__ ((section(".main")))
int main(int param, int ram, int rom, int (*divfunc)()) {
int res;
uint8_t buf[0x100];
// change flash!
disable_irq();
int sec = flash_blankCheck(6, 6) == IAPRESULT_CMD_SUCCESS ? 6 : 7;
const int sec5 = 5;
// copy sec5 + newdata -> sec
for (int i = 0; i < 16; i++) {
// i == 7 : Keyboard
// i == 8 : PCG #00-#1F i == 12 : PCG #80-#9F
// i == 9 : PCG #20-#3F i == 13 : PCG #A0-#BF
// i == 10 : PCG #40-#5F i == 14 : PCG #C0-#DF
// i == 11 : PCG #60-#7F i == 15 : PCG #E0-#FF
if (i == 13) {
memcpy(buf, (uint8_t*)(ram + 0xE00), 0x100);
} else if (i == 14) {
memcpy(buf, (uint8_t*)(ram + 0xF00), 0x100);
} else {
memcpy(buf, (uint8_t*)(sec5 * 0x1000 + 0x100 * i), 0x100);
}
flash_prepare(sec, sec);
flash_copyRAMtoFlash((uint8_t*)(sec * 0x1000 + 0x100 * i), buf, 0x100);
}
// erase sector5
flash_prepare(sec5, sec5);
flash_erase(sec5, sec5);
// copy sec -> sector5
for (int i = 0; i < 16; i++) {
memcpy(buf, (void*)(sec * 0x1000 + 0x100 * i), 0x100);
flash_prepare(sec5, sec5);
flash_copyRAMtoFlash((uint8_t*)(sec5 * 0x1000 + 0x100 * i), buf, 0x100);
}
// erase sec
flash_prepare(sec, sec);
res = flash_erase(sec, sec);
enable_irq();
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment