Skip to content

Commit

Permalink
updated to last SGDK
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane-D committed Jul 12, 2023
1 parent ba2a3ff commit e3bcd94
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 29 deletions.
Binary file modified sample/platformer/out/rom.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion sample/platformer/src/boot/rom_head.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ROMHeader rom_header = {
#else
"SEGA MEGA DRIVE ",
#endif
"(C)SGDK 2022 ",
"(C)SGDK 2023 ",
"SAMPLE PROGRAM ",
"SAMPLE PROGRAM ",
"GM 00000000-00",
Expand Down
47 changes: 19 additions & 28 deletions sample/platformer/src/boot/sega.s
Original file line number Diff line number Diff line change
Expand Up @@ -52,49 +52,40 @@ rom_header:
.incbin "out/rom_head.bin", 0, 0x100

_Entry_Point:
* disable interrupts
move #0x2700,%sr

* Configure a USER_STACK_LENGTH bytes user stack at bottom, and system stack on top of it
move %sp, %usp
sub #USER_STACK_LENGTH, %sp

* Halt Z80 (need to be done as soon as possible on reset)
move.l #0xA11100,%a0 /* Z80_HALT_PORT */
move.w #0x0100,%d0
move.w %d0,(%a0) /* HALT Z80 */
move.w %d0,0x0100(%a0) /* END RESET Z80 */

tst.l 0xa10008
bne.s SkipJoyDetect
bne.s SkipInit

tst.w 0xa1000c
bne.s SkipInit

SkipJoyDetect:
bne.s SkipSetup

lea Table,%a5
movem.w (%a5)+,%d5-%d7
movem.l (%a5)+,%a0-%a4
* Check Version Number
move.b -0x10ff(%a1),%d0
move.b -0x10ff(%a0),%d0
andi.b #0x0f,%d0
beq.s WrongVersion
beq.s NoTMSS

* Sega Security Code (SEGA)
move.l #0x53454741,0x2f00(%a1)
WrongVersion:
* Read from the control port to cancel any pending read/write command
move.w (%a4),%d0

* Configure a USER_STACK_LENGTH bytes user stack at bottom, and system stack on top of it
move %sp, %usp
sub #USER_STACK_LENGTH, %sp

move.w %d7,(%a1)
move.w %d7,(%a2)

* Jump to initialisation process now...
move.l #0x53454741,0x2f00(%a0)

NoTMSS:
jmp _start_entry

SkipSetup:
SkipInit:
jmp _reset_entry


Table:
dc.w 0x8000,0x3fff,0x0100
dc.l 0xA00000,0xA11100,0xA11200,0xC00000,0xC00004


*------------------------------------------------
*
* interrupt functions
Expand Down

0 comments on commit e3bcd94

Please sign in to comment.