Booting CD from Cart ?
Moderator: Mask of Destiny
Booting CD from Cart ?
I have problems writing my own cd boot program, it works well on emulators, but not on real hardware.
The problem is, I don't want to waste a cd for each test, so I was wondering, is there a way to start the mega cd hardware and make it boot some code from a cartridge program ?
If yes, then I could use my everdrive cart to test my program more easily without the need to burn a cd.
The problem is, I don't want to waste a cd for each test, so I was wondering, is there a way to start the mega cd hardware and make it boot some code from a cartridge program ?
If yes, then I could use my everdrive cart to test my program more easily without the need to burn a cd.
Retro game programming !
-
- Very interested
- Posts: 53
- Joined: Mon Mar 07, 2011 12:58 am
Find a copy of the FLUX ROM http://www.youtube.com/watch?v=Oswpqv22TIg
You can disassemble it and see how it works.
It boots from Cartridge and can control the CD unit completely.
You can disassemble it and see how it works.
It boots from Cartridge and can control the CD unit completely.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
No need - I already posted an example of using Mode 1 to control the CD from a cart.
viewtopic.php?t=1018
I've also posted several different examples of CD code that works properly on real hardware.
viewtopic.php?t=1385
viewtopic.php?t=1403
viewtopic.php?t=1407
viewtopic.php?t=1018
I've also posted several different examples of CD code that works properly on real hardware.
viewtopic.php?t=1385
viewtopic.php?t=1403
viewtopic.php?t=1407
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
No problem. You wouldn't happen to be looking into a SCD version of Elansar, would you? I bought the Jaguar cart version of that... great game!
Anywho, when I'm trying out CD programming, I buy bulk spindles of 100 CDRs so that it only costs 10 cents or so per disc. The larger the spindle, the better the savings per disc. I also use some on Dreamcast debugging. I must have gone through 80 CDRs while working on Doom for DC.
Anywho, when I'm trying out CD programming, I buy bulk spindles of 100 CDRs so that it only costs 10 cents or so per disc. The larger the spindle, the better the savings per disc. I also use some on Dreamcast debugging. I must have gone through 80 CDRs while working on Doom for DC.
-
- Very interested
- Posts: 2440
- Joined: Tue Dec 05, 2006 1:37 pm
- Location: Estonia, Rapla City
- Contact:
The drives do not read CD-RW, and making them read one will destory the drive pretty quick.
Mida sa loed ? Nagunii aru ei saa
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
seems like I've no luck with the mega cd :'(
I tried to copy the exact behavior of chilly willy mode 1 program in my own (in assembly) and it doesn't work, like the cd sub cpu is not running my sub program
I'm a bit despaired about the cd :/
here is my code:
sub cpu:
[/code]
I tried to copy the exact behavior of chilly willy mode 1 program in my own (in assembly) and it doesn't work, like the cd sub cpu is not running my sub program
I'm a bit despaired about the cd :/
here is my code:
Code: Select all
dc.l $01000000 ; Stack
dc.l _Start
dc.l _Error,_Error,_Error,_Error,_Error,_Error,_Error,_Error,_Error,_Error,_Error
dc.l _Error,_Error,_Error,_Error,_Error,_Error,_Error,_Error,_Error,_Error,_Error
dc.l _Error,_INT,_EXTINT,_INT,_HINT,_INT,_VINT,_INT
dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT
dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT
dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT
dc.l _INT,_INT,_INT,_INT,_INT,_INT,_INT,_INT
dc.b "SEGA MEGA DRIVE " ; Console Name
dc.b "<=- Orion_ =-> " ; Copyright
dc.b "SAMPLE PROGRAM " ; Game Name
dc.b "SAMPLE PROGRAM " ; Overseas Name
dc.b "GM 00000000-00" ; Serial
dc.w $0000 ; Checksum
dc.b "J " ; IO Support
dc.l $00000000 ; Rom Start
dc.l $00010000 ; Rom End
dc.l $00FF0000 ; Backup RAM Start
dc.l $00FFFFFF ; Backup RAM End
dc.b " " ; "RA" for Backup RAM
dc.w $0000 ; $F820 for Backup RAM on odd bytes
dc.l $00200000 ; SRAM Start
dc.l $002001FF ; SRAM End
dc.b " " ; Modem
dc.b "DEMONSTRATION PROGRAM " ; Note
dc.b "JUE " ; Country
VDP_DATA equ $C00000
VDP_CTRL equ $C00004
MAINCPU_CMD equ $A1200E
SUBCPU_CMD equ $A1200F
; VRam Mapping (from VDPtable configuration)
VRAM_TILE equ $0000 ; 44k
VRAM_WINDOW equ $B000 ; 2k
VRAM_HSCROLL equ $B800 ; 1k
VRAM_SPRITE equ $BC00 ; 1k
VRAM_LAYER_A equ $C000 ; 8k
VRAM_LAYER_B equ $E000 ; 8k
;---------------------------------------->
_Start:
move #$2700,sr
tst.l $A10008
bne.s SkipJoyDetect
tst.w $A1000C
SkipJoyDetect:
bne.s SkipSetup
; Sega Security Code (SEGA)
move.b $A10001,d0
andi.b #$0F,d0
beq.s WrongVersion
move.l #'SEGA',$A14000
WrongVersion:
SkipSetup:
move.w #$8104,$C00004 ; display off, vblank disabled
move.w $C00004,d0
; Clear RAM
lea $ff0000,a0
moveq #0,d0
move.w #((1<<16)/4)-1,d1 ; 64k of RAM
ClearRam:
move.l d0,(a0)+
dbra d1,ClearRam
;----
_CDStart:
lea $1000000,a7
; Clear VRAM
moveq #0,d0
bsr SetVramAddress
lea VDP_DATA,a1
moveq #0,d0
move.w #((1<<16)/2)-1,d1 ; 64k of VRAM
ClearVRam:
move.w d0,(a1)
dbra d1,ClearVRam
;----
move.w #$0100,d0
move.w d0,$A11100 ; Z80 Bus Request
move.w d0,$A11200 ; Z80 Request Reset
;----
lea $A10000,a0 ; Joypad 1&2 Init
moveq #$40,d0
move.b d0,$9(a0)
move.b d0,$B(a0)
move.b d0,$3(a0)
move.b d0,$5(a0)
;----
; Init VDP
lea VDPregs,a0
lea $C00004,a1
moveq #19-1,d0
move.w #$8000,d1
VDPiLoop:
move.b (a0)+,d1 ; Reg Value from Table
move.w d1,(a1) ; Send to VDP
add.w #$0100,d1 ; Reg++
dbra d0,VDPiLoop
move.w #VRAM_HSCROLL,d0
bsr SetVramAddress
move.w #0,VDP_DATA ; HScroll = 0
move.w #$0000,d0 ; VScroll
bsr SetVSramAddress
move.w #0,VDP_DATA ; = 0
;---------------------------------------->
; move #$2000,sr
;---------------------------------------->
; Main Code
; Reset the Gate Array
move.w #$FF00,$A12002
move.b #3,$A12001
move.b #2,$A12001
move.b #0,$A12001
; Reset the Sub-CPU, Request bus
lea $A12001,a0
moveq #2,d1
.waitack:
move.b d1,(a0)
move.b (a0),d0
and.b d1,d0
beq.s .waitack
; Decompress Sub-CPU BIOS to Program RAM at 0x00000
move.w #2,$A12002 ; no write-protection, bank 0, 2M mode, Word RAM assigned to Sub-CPU
lea $420000,a0
move.w #($20000/4)-1,d1
moveq #0,d0
.clrpram:
move.l d0,(a0)+
dbra d1,.clrpram
move.l $416000,a0
lea $420000,a1
bsr Kos_Decomp
lea Sub_CPU_Prg,a0
lea $426000,a1
move.w #((Sub_CPU_PrgE-Sub_CPU_Prg)/2)-1,d0
.subcpucopy:
move.w (a0)+,(a1)+
dbra d0,.subcpucopy
move.b #0,$A1200E ; clear main comm port
move.b #$2A,$A12002 ; write-protect up to 0x05400
; clear bus request, deassert reset - allow CD Sub-CPU to run
; and Wait Ack
lea $A12001,a0
moveq #1,d1
.waitack2:
move.b d1,(a0)
move.b (a0),d0
and.b d1,d0
beq.s .waitack2
move.l #gen_lvl2,VBLptr
move #$2000,sr
;------>
Loop:
moveq #10,d0 ; X
moveq #6,d1 ; Y
moveq #0,d2
move.b SUBCPU_CMD,d2
bsr PrintHex
bsr WaitVBL
jmp Loop
gen_lvl2:
movem.l d0/a0,-(a7)
lea $A12000,a0
move.w (a0),d0
ori.w #$0100,d0
move.w d0,(a0)
movem.l (a7)+,d0/a0
rte
;---------------------------------------->
; Utils
;------>
WaitVBL:
lea VDP_CTRL,a0
.wait: move.w (a0),d0
andi.w #8,d0
bne.s .wait
rts
[.... extra sub routines ...]
;---------------------------------------->
; Interrupts
_Error:
rte
_INT:
rte
_EXTINT:
rte
_HINT: ; Should be enabled in VDP Register 0 ($10)
rte
_VINT: ; Should be enabled in VDP Register 1 ($20)
move.l VBLptr,-(a7)
beq.s .noptr
rts
.noptr: addq.l #4,a7
rte
;---------------------------------------->
; Datas
VDPregs: dc.b $04,$7C,$30,$2C,$07,$5E,$00,$00,$00,$00,$01,$00,$81,$2E,$00,$02,$11,$00,$FF
even
include "kos.s"
even
Sub_CPU_Prg: incbin "subcpu.bin"
Sub_CPU_PrgE:
; 64k ROM Padding
org $00010000
; BSS in RAM
VBLptr equ $FF0000
Code: Select all
org $6000
Header:
dc.b "MAIN-SUBCPU",0
dc.w 1,0
dc.l 0
dc.l 0
dc.l JumpTable-Header
dc.l 0
JumpTable:
dc.w SP_Init-JumpTable
dc.w SP_Main-JumpTable
dc.w SP_IRQ-JumpTable
dc.w SP_IRQ-JumpTable
dc.w 0
MAINCPU_CMD equ $FFFF800E
SUBCPU_CMD equ $FFFF800F
MAINCPU_DATA equ $FFFF8010
SUBCPU_DATA equ $FFFF8020
;----
SP_Init:
move.b #$00,SUBCPU_CMD.w ; Clear ComFlag
andi.b #$E2,$FFFF8003.w ; Set WordRAM to 2M Mode
rts
;----
SP_Main:
move.b #$01,SUBCPU_CMD.w
LOOP: bra.s LOOP
Retro game programming !
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Hmm - don't see anything right off. I suggest setting the background color register to different colors at different places in the code to get an idea of how far it is getting. Maybe a minor typo is making it fail in the decompression - or clearing the ram - or any one of a dozen other places. One wrong register number and you can easily fail. I like using the background color method for debugging real hardware. It's easy to set and always shows.
Code: Select all
move.l $416000,a0
lea $420000,a1
bsr Kos_Decomp
ok so, after some few test, I know where my program hangs.
From the Sub CPU program, when I try to load data from cd to the cd ram, it works if I load data in PRG RAM, for example at $7000
but it doesn't work (infinite loop when calling CDCTRN) when I try to load data in the Word Ram ($80000)
Is there something special to do when loading data in word ram ?
I initialize with this command: move.b #2,$FFFF8003.w
I also tried to write at $80000 using 68k code, and it also hangs the sub cpu :/
From the Sub CPU program, when I try to load data from cd to the cd ram, it works if I load data in PRG RAM, for example at $7000
but it doesn't work (infinite loop when calling CDCTRN) when I try to load data in the Word Ram ($80000)
Is there something special to do when loading data in word ram ?
I initialize with this command: move.b #2,$FFFF8003.w
I also tried to write at $80000 using 68k code, and it also hangs the sub cpu :/
Retro game programming !