Skip to content

Instantly share code, notes, and snippets.

View ketsuban's full-sized avatar

Thomas Winwood ketsuban

View GitHub Profile
@ketsuban
ketsuban / linker.ld
Created December 13, 2021 11:08
Linker script for a Rust executable crate targeting the GBA
ENTRY(__start)
/*
* The GBA has two sections of work RAM: internal and external. Internal work
* RAM is essentially instantaneous to access and sits on a 32-bit bus, so it's
* suitable for ARM code. External work RAM has a delay of two clock cycles and
* sits on a 16-bit bus.
*/
MEMORY {
rom (rx) : ORIGIN = 0x08000000, LENGTH = 32M
@ketsuban
ketsuban / functions.cfg
Created November 30, 2021 03:54
Half-finished functions.cfg for running gbadisasm on Yu-Gi-Oh: World Championship Tournament 2006
arm_func 0x80000fc IntrMain
thumb_func 0x8014398 sub_8014398
thumb_func 0x80143f0 sub_80143f0
thumb_func 0x8014470 sub_8014470
thumb_func 0x8014480 sub_8014480
thumb_func 0x80144e8 sub_80144e8
thumb_func 0x801455c sub_801455c
thumb_func 0x80145bc sub_80145bc
thumb_func 0x8014600 sub_8014600
thumb_func 0x8014638 sub_8014638
@ketsuban
ketsuban / filenames.txt
Created July 8, 2021 07:30
Yu-Gi-Oh! Ultimate Masters - World Championship Tournament unique file names
inc/nitro/fx_mtx22.h
inc/nitro/g2_oam.h
inc/nnsys/g2d/fmt/g2d_Anim_data.h
inc/nnsys/g2d/fmt/g2d_Cell_data.h
inc/nnsys/g2d/load/g2d_NAN_load.h
inc/nnsys/g2d/g2d_Image.h
inc/nnsys/g2d/g2d_Animation_inline.h
inc/nnsys/g2d/g2d_CellAnimation.h
inc/nnsys/g2d/g2d_SRTControl.h
nnsys/g2d/g2di_OamUtil.h
@ketsuban
ketsuban / main.c
Created October 12, 2020 16:32
The sum total of my progress decompiling Advance Wars
#include "hardware.h"
#include "types.h"
struct sub_807AEE0_arg1 {
u8 _bytepad1;
u8 field1;
u8 _bytepad2;
u8 _bytepad3;
u32 _longpad1;
u32 _longpad2;
@ketsuban
ketsuban / main.c
Created September 18, 2020 19:56
Yu-Gi-Oh! Ultimate Masters - World Championship Tournament 2006's AgbMain function
u8 dat_2000000;
u16 dat_200AF10;
void (*dat_2029EA0)(u32, u8 *, u16);
void sub_80F48F8(void (*)(void));
void sub_80F4B94(void);
void sub_80F4C14(void);
void sub_80F9BE4(u32);
u32 sub_80F9C40(void);
void sub_80FBAD0(void);

Keybase proof

I hereby claim:

  • I am ketsuban on github.
  • I am ketsuban (https://keybase.io/ketsuban) on keybase.
  • I have a public key ASBMMSOWA5veoN9WZHxE87y-2HyNrk-5cd-I_D4vRhWsAQo

To claim this, I am signing this object:

@ketsuban
ketsuban / ideas.md
Last active December 25, 2023 22:59
Things I'd like to have a go at but don't really know where to start
  1. Star Trek: The Next Generation: A Final Unity game engine recreation

    I like this game, but right now if you own it and want to play it you need to set up DOSbox, and that's lame. All its data files seem to be stored in a single directory on the CD, so an executable which can read those would be very cool.

    Prior art: There's an okay resource for file formats but its focus is on data dumping, so there's no documentation that I can find on which files constitute behaviour and how they're arranged. There's also this unfinished attempt to implement the game in ScummVM, but since it's written in C++ it's basically gibberish and the impetus to finish it dissolved when DOSbox gained support for the original.

  2. Magic: the Gathering simulator

Magic is fun[citation needed], but playing it online sucks. Wizards of the Coast has actually put effort into a couple pieces of software that simulate the effect o

Add a debug menu to pokeemerald

During development it's common for your game to be partially complete; even if it isn't, you probably don't want to spend a whole bunch of time playing through the game to get to the bit you need to test. As such, it's useful to have a debug menu with a collection of tools defined in code to do useful things for you which you don't expose to the players. However, pokeemerald reproduces the commercial release of Pokémon Emerald, so there's no debug functionality at all. Fortunately we're programmers, so we can fix that.

I assume a reasonable familiarity with C, so I won't be explaining things like preprocessor directives, include guards, what a structure or its fields are, or the like. If you want or need to look these things up, you now know what to search for.

Step 0: Add a compile flag

There's no reason to expose the debug menu to the players, so it's a good idea to keep it behind a compile flag just like Game Freak did. This is technically optional,

zsh users are advised to use the terminfo database as the most portable way to assign commands to particular keychords, but I haven't been able to find a database of which terminfo sigils correspond to which keys. Fortunately, I found enough information written in ancient Sumerian that I could translate it into something modern humans can comprehend.

Key Chord Terminfo Name
Backspace kbs
Ctrl-Backspace cub1
Insert kich1
Shift-Insert kIC
Alt-Insert kIC3
Shift-Alt-Insert kIC4