Introduction
Mucking around on the Megadrive learning by doing on linux, starting from zero
No sure how far this will go ....
Tools
- MAME (0.227 debug)
- asmx (2.0b5)
- (megadrive) init.asm from https://github.com/db-electronics/68kTutorials/tree/master/01-HelloWorld
Assuming you have a build environment for c (e.g build-essentials meta package
on debian)
Compile asmx
- Download asmx-2.0b5.zip
- Unpack and cd asmx-2.0b5/
- Edit the Makefile and comment out the default TARGET line
- Buld the sources ./make
- cp ./src/asmx to a location in your PATH (e.g /usr/local/bin)
The basic workflow from here on out is pretty simple
- Create the directory structure including init.asm
- Write you Assembly code
- Build a Megadrive ROM with asmx
- Run the rom in MAME with debugger
Memory
TBA
Basic Movement
The most basic of all operations we can do here is _not_ writing Hello World
to the screen as per every other language. Here we will do very basic data
movement by defining the simplest program we can to update a data register in
memory.
Setup the projects directory
- create a project_dir
- download init.asm to project_dir
Create the Assembly source file
; source example
; ----------------------------------------------
; Assembly 68k basic data manipulation
;
; insert a value into a data register
;
include 'init.asm'
__main:
move.b #1, d0 ; put 1 (byte) into data register 0
__end:
; ----------------------------------------------
- note: the whitespace before include, when i work out why *** UPDATE THIS***
- save this program as basic_movement.asm in project_dir
Build a Megadrive ROM with asmx
- build the rom
$ asmx -C 68000 -e -w -b 0 -l basic_movement.lst -o basic_movement.bin -- basic_movement.asm
Run the rom in MAME with debugger
You will now run the built rom in MAME with the debugger enabled to watch the
data register be updated, there is no fancy graphics here.
$ mame genesis -cart /basic_movement.bin -debug
The rom will load and the debugger will sit idle waiting for an instruction
from you.
Note the pane on the left hand side of the debugger screen, this is the
registers.
note the value of d0
Press F5 to run to the end of the current program.
Once the program run has completed you will see a value of 1 against d0
Data Movement with Subroutines
TBA
References
References
- https://www.retrodev.com/68ktut1.html
- https://github.com/db-electronics/68kTutorials/
- https://www.plutiedev.com/
- https://gendev.spritesmind.net/page-doc.html
- https://archive.org/details/Genesis_Technical_Overview_v1.00_1991_Sega_US/mode/2up
- https://www.youtube.com/playlist?list=PLp_QNRIYljFoy1iv8BG9HykORt_g342IV