Why does this not run on real HW?

Announce (tech) demos or games releases

Moderator: Mask of Destiny

Post Reply
Oerg866
Very interested
Posts: 211
Joined: Sat Apr 19, 2008 10:58 am
Location: Frankfurt, Germany
Contact:

Why does this not run on real HW?

Post by Oerg866 » Thu Nov 26, 2009 8:45 am

Code: Select all

 ORG    $00000000

 DC.L   $00FFFFFE, CodeStart, Bus_Error, AddrError   ; SP, PS, BusEr, AddrEr
 DC.L   Illg_Inst, DivByZero, CHK___int, TRAPV_int   ; ILL, DIV0, CHK, TRAPV
 DC.L   Priv_Viol, TRACE_int, LineA_emu, LineF_emu   ; PRIV, TRACE, LA, LF
 DC.L   Interrupt, Interrupt, Interrupt, Interrupt
 DC.L   Interrupt, Interrupt, Interrupt, Interrupt
 DC.L   Interrupt, Interrupt, Interrupt, Interrupt
 DC.L   Interrupt, Interrupt, Interrupt, Interrupt   ; Spurious, 1, Ext, 3
 DC.L   HBlankInt, Interrupt, VBlankInt, Interrupt   ; Hint, 5, Vint, 7
 DC.L   Interrupt, Interrupt, Interrupt, Interrupt
 DC.L   Interrupt, Interrupt, Interrupt, Interrupt
 DC.L   Interrupt, Interrupt, Interrupt, Interrupt
 DC.L   Interrupt, Interrupt, Interrupt, Interrupt
 DC.L   Interrupt, Interrupt, Interrupt, Interrupt
 DC.L   Interrupt, Interrupt, Interrupt, Interrupt
 DC.L   Interrupt, Interrupt, Interrupt, Interrupt
 DC.L   Interrupt, Interrupt, Interrupt, Interrupt
 DC.B   "SEGA MEGA DRIVE "     ; System name
 DC.B   "(C)Oerg 2009.NOV"     ; Copyright
 DC.B   "ReCoMe Italo Disco                              "   ; Name (local)
 DC.B   "ReCoMe Italo Disco                              "   ; Name (int.)
 DC.B   "GM T-ReCoMe-00"      
 DC.W   $0000                  ; Checksum
 DC.B   "J               "     ; I/O support
 DC.L   $00000000, $003FFFFF   
 DC.L   $00FF0000, $00FFFFFF   
 DC.B   $00000000              
 DC.L   $00000000, $00000000   
 DC.B   "No modem... "         ; Modem shit      
 DC.B   "                                        "
 DC.B   "E               "     ; Regions

ROMSIZE  EQU $0001A4    
SRAMA    EQU $200000    
FMPORT1  EQU $A04000    
FMPORT2  EQU $A04001   
FMPORT3  EQU $A04002    ; YM2612 Data port, set 2
FMPORT4  EQU $A04003    ; YM2612 Index port, set 2
SRAMEN   EQU $A130F1    ; SRAM control port
DPORT    EQU $C00000    ; VDP Data port
CPORT    EQU $C00004    ; VDP Command port
P1CTRL   EQU $FF0000    ; P1 controller status address
P2CTRL   EQU $FF0001    ; P2 controller status address
HTIMER   EQU $FF0002    ; HBlank based timer
VTIMER   EQU $FF0006    ; VBlank based timer
PTADDR   EQU $FF000A    ; Pattern table address
TXTATTR  EQU $FF000C    ; Text attributes
TXTCHAR  EQU $FF000E    ; PrintChar character
GFXATTR  EQU $FF0010    ; Graphics attributes
TXTX     EQU $FF0012    ; Text X position
TXTY     EQU $FF0014    ; Text Y position
GARBAGE  EQU $FF0016    ; GiveGarbage random number/seed
FADESPD  EQU $FF0018    ; Palette fading speed
TXTSPD   EQU $FF001A    
BMPX     EQU $FF001E    ; Bitmap file X info for BMP loader routine
BMPY     EQU $FF0020    ; Bitmap file Y info for BMP loader routine
NUMBUF   EQU $FF0024    ; Decimal number buffer
FIFOPAL  EQU $FF002C    

CodeStart:

 MOVE.W #$2700, SR      ; Disable ints

 INCLUDE "TMEGALIB/SEGASEQ.ASM"   ; Need it to get code running on real HW

; MOVE.L #$FF0000, A0    ; Clear the RAM
; MOVE.W #$3FFF, D0
;RAMclearLoop:
; MOVE.L #0, (A0)+
; DBRA   D0, RAMclearLoop

 JSR    Initial_VDP_setup
 JSR    ClearTables     ; Clear A/B/Sprites

 JSR    Z80startUp      ; Starts Z80 WAV player

; JSR    VerifyChecksum  ; Verify checksum
; JSR    CheckSRAM       ; Check if SRAM is present
 JSR    InitControls    ; Initialize controllers for use

 MOVE.L #4, (FADESPD)   
 MOVE.L #0, (HTIMER)    
 MOVE.L #0, (VTIMER)
 MOVE.W #25510, (GARBAGE) 
 MOVE.W #$2000, SR      ; Enable ints

 LEA    TitlePal, A0
 CLR.L  D0
 JSR    LoadPalette

 JMP    SkipThisStuff

 INCLUDE "TMEGALIB\REGION.ASM"    
 INCLUDE "TMEGALIB\DMA.ASM"       
 INCLUDE "TMEGALIB\Z80SOUND.ASM"  
 INCLUDE "TMEGALIB\68KSOUND.ASM"  
 INCLUDE "TMEGALIB\YM2612.ASM"    
 INCLUDE "TMEGALIB\GARBAGE.ASM"   
 INCLUDE "TMEGALIB\NUMSTEXT.ASM" 
 INCLUDE "TMEGALIB\PALETTE.ASM"  
 INCLUDE "TMEGALIB\TIMING.ASM" 
 INCLUDE "TMEGALIB\TILESHIT.ASM" 
 INCLUDE "TMEGALIB\VDP.ASM"   
 INCLUDE "TMEGALIB\SRAM.ASM"     
 INCLUDE "TMEGALIB\CONTROL.ASM" 
 INCLUDE "TMEGALIB\OVRCLOCK.ASM"  

ExtrnlInt:              
 LEA    ExtInt, A0
 BRA    PrintInt
Bus_Error:              
 LEA    BusError, A0
 BRA    PrintInt
AddrError:              
 LEA    AError, A0
 BRA    PrintInt
Illg_Inst:              
 LEA    IlgInstr, A0
 BRA    PrintInt
DivByZero:              
 LEA    DivZ, A0
 BRA    PrintInt
Priv_Viol:              
 LEA    PriViol, A0
 BRA    PrintInt
LineA_emu:             
 LEA    LineA, A0
 BRA    PrintInt
LineF_emu:              
 LEA    LineF, A0
 BRA    PrintInt
Interrupt:              
 LEA    Xint, A0
 BRA    PrintInt
PrintInt:               
 MOVE.L #$C01E0000, (CPORT)
 MOVE.W #$0EEE, (DPORT)
 MOVE.W #0, (TXTY)
 MOVE.W #0, (TXTX)
 JSR    PrintString
 JSR    IdleLoop
 RTE

TRACE_int:             
 RTE
CHK___int:             
 RTE
TRAPV_int:             
 RTE

VBlankInt:             
 ADDQ.L #1, (VTIMER)
 RTE

HBlankInt:            
 ADDQ.L #1, (HTIMER)
 RTE

ExtInt:
 DC.B   17, "External interrupt"
 EVEN
BusError:
 DC.B    8, "Bus Error"
 EVEN
AError:
 DC.B   12, "Address Error"
 EVEN
IlgInstr:
 DC.B   18, "Illegal Instruction"
 EVEN
DivZ:
 DC.B   15, "Division By Zero"
 EVEN
PriViol:
 DC.B   18, "Privilege violation"
 EVEN
LineA:
 DC.B   16, "Line $A emulator"
 EVEN
LineF:
 DC.B   16, "Line $F emulator"
 EVEN
Xint:
 DC.B   17, "Unknown interrupt"
 EVEN

IdleLoop:         
 JMP    IdleLoop

ASCIItiles:
 INCLUDE "ASCII701.TGS"     
      
DefaultPal:
 DC.L    $00000000, $00000000, $00000000, $00000EEE

 EVEN    ; just in case


SkipThisStuff:
	lea TitleScreen,a0
	move.w #200,d0
	move.w #316,d3
	jsr loadtiles
	move.l #$F,d0
	move.l #$0,d1
	move.l #200,d3
	move.l #$27,d4
	move.l #$6,d5
	jsr PutTiles
	clr d3
	lea Recome,a0
 MOVE.L #$C01E0000, (CPORT)
 MOVE.W #$0EEE, (DPORT)
 MOVE.W #0, (TXTY)
 MOVE.W #0, (TXTX)
 JSR    PrintString
 MOVE.W #2, (TXTY)
	lea Copy,a0
	jsr PrintString
 MOVE.W #9, (TXTY)
	lea Ctrl,a0
	jsr PrintString

	lea Jasmin,a0
 MOVE.W #5, (TXTY)
 JSR    PrintString
	jsr z80Startup
	lea Wav01, a0
	jsr PlayWAV
	moveq #0,d6	
	clr.l d5
	jsr InitControls

Menu:
	nop
	nop
	nop
	nop
	nop
	clr.l d5
	jsr ReadControl1
	btst #2, d5
	bne Left
	btst #3, d5
	bne Right
	cmp.b #$2, d2
	beq TripCalc
	cmp.b #$1, d2
	beq MindCalc
	bra JasminCalc
	jmp Menu

Left:
	clr.l d0
	moveq #0, d0
	jsr GiveCommand
	move.l #$FFff,d0
	jsr wait12
	sub.b #1, d2
	cmp.b #$FF, d2
	bne Left2
	moveq #$2, d2
Left2:
	move.l #0,a0
	cmp.b #$0, d2
	beq Load0
	cmp.b #$1, d2
	beq load1
	cmp.b #$2, d2
 	beq load2

	jmp menu2



Right:
	clr.l d0
	moveq #0, d0
	jsr GiveCommand
	move.l #$FFff,d0
	jsr wait12
	add.b #1, d2
	cmp.b #$3, d2
	bne Right2
	moveq #$0, d2
Right2:
	move.l #0,a0
	cmp.b #$0, d2
	beq Load0
	cmp.b #$1, d2
	beq load1
	cmp.b #$2, d2
 	beq load2

	jmp menu2

Load0:
	clr.l d3
	lea Jasmin,a0
 MOVE.L #$C01E0000, (CPORT)
 MOVE.W #$0EEE, (DPORT)
 MOVE.W #5, (TXTY)
 MOVE.W #0, (TXTX)
 JSR    PrintString
	lea Wav01,a0
	nop
	nop
	nop
	nop
	jsr PlayWAV
	jsr PlayWAV
	jmp menu2
	
Load1:
	clr.l d3
	lea Mind,a0
 MOVE.L #$C01E0000, (CPORT)
 MOVE.W #$0EEE, (DPORT)
 MOVE.W #5, (TXTY)
 MOVE.W #0, (TXTX)
 JSR    PrintString
	lea Wav02,a0
	nop
	nop
	nop
	nop
	jsr PlayWAV
	jsr PlayWAV
	jmp menu2

Load2:
	clr.l d3
	lea Trip,a0
 MOVE.L #$C01E0000, (CPORT)
 MOVE.W #$0EEE, (DPORT)
 MOVE.W #5, (TXTY)
 MOVE.W #0, (TXTX)
 JSR    PrintString
	lea Wav03,a0
	nop
	nop
	nop
	nop
	jsr PlayWAV
	jmp menu2

wait12:
	clr.l d4
WaitDo:
	nop
	add.l #1,d4
	cmp.l d0, d4
	bne WaitDo
	rts


idlelop:
	jmp idlelop



Menu2:
	jmp menu
	
JasminCalc:
	cmp.l #$1F7000,d3 
	bne Jasmin2
	jmp load0	
Jasmin2:
	add.l #1,d3
	jmp menu2

TripCalc:
	cmp.l #$219FFF,d3
	bne Trip2
	jmp load2	
Trip2:
	add.l #1,d3
	jmp menu2

MindCalc:
	cmp.l #$1EEA8F,d3
	bne Mind2
	jmp load1	
Mind2:
	add.l #1,d3
	jmp menu2
 
	align $1000
Wav01: incbin "jasmin.wav"
wav01_End: even

Wav02: incbin "mind.wav"
wav02_end: even

wav03: incbin "spacet~1.wav"
Wav03_End: even

Jasmin:
	dc.b 30,"Mozzart - My Jasmin China Girl "
	even
Mind:
	dc.b 30,"Laserdance - Make Up Your Mind "
	even
Trip:
	dc.b 30,"Laserdance - Space Trip        "
	even
Recome:
	dc.b 39,"ReCoMe - Sega Mega Drive -- Italo Disco!"
	even
Copy:
	dc.b 38,"Program by Oerg866, Z80 Driver by TmEE!"
	even
Ctrl:
	dc.b 37,"Move D-Pad Left / Right to change song"
	even

TitleScreen: incbin "logo.bin"
	even
TitlePal:	incbin "logopal.bin"
	end
Made this thingy with help of Tiido's Mega Lib. It works fine in kega fusion 3.51 (no newer version on this PC right now :P), but garbles the BG when selecting it from the tototek menu on real hardware.

Can someone tell me what I am doing wrong?

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Nov 26, 2009 2:47 pm

here's my 3 year old crappy ASM code library Oerg is using to make the stuff :
http://www.fileden.com/files/2008/4/21/ ... EGALIB.RAR
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

Post Reply