PDA

View Full Version : [MEGA DRIVE] ASM68K giving me trouble :(



segaloco
04-04-2010, 11:02 PM
http://uploading.com/files/37ef6da3/PROJECT.7z/

Can anyone help me out with that :( It won't assemble, even though all logic and everything I know says it should...:pray:

SONIC3D
04-29-2010, 05:53 AM
The Z80 assembler you supplied is not working.But the Z80.BIN is already the result of the binary code of Z80.I.So I will bypass how to compile z80 code.If you want to there is other z80 assembler out there.

The Z80.bin will be binary included by main.asm near the bottom of it.


=============
Z80Driv:
incbin "Z80.BIN"
Z80DrivEnd:
=============


The main.asm is not compilable due to the included file end the source code too early.
You need to modify 2 file to get main.asm compiled.

In bottom of Main.asm,there is


======================
include "SEGALOGO.SUB"
include "UTIL.H"
======================


1.Modify SEGALOGO.SUB
Remove the last 2 line from this file or the source code will be ended and "UTIL.H" will not be included.


=========REMOVE===========
596: end:
597: end
==========================


2.Modify Util.h
Because there are subroutine in Util.h that uses undeclared var.It will cause compile error.Although it's not very complicate to solve it perfectly,I prefer removing those unused subsoutine in this file.(UNUSED means unused by main.asm or other including file in main.asm).And same as SEGALOGO.SUB,the last "end" should be removed,too.In case you wanna include more files after "util.h" in "main.asm".

The only subroutine need to be kept is _JOYGET6.So after removing other subroutines.The file looks like this:


==========================================
************************************************** ***************************
*
* Utility routines for genesis
*
*
************************************************** ***************************
Z80BusReq equ $A11100 * bit 8 (high=BusReq)
Z80Reset equ $A11200 * bit 8 (low=Reset)
************************************************** *********************************
* _JOYGET6 joystick data get ( six button and three button )
* THIS DRIVER READS BOTH THE SIX AND THREE BUTTON PADS
* ID checking and distinguishing between the three button and the
* six button controllers is done while driver actually gets data
* from the controllers. The above feature will allow the user to
* interchange controllers.
* If any device that uses a handshaking scheme( eg MOUSE) is plugged
* in, the routine returns value 0 in register d0.l Also if nothing is
* connected, the driver returns value 0 in register d0.l
* In case of three and six button controllers the driver
* cannot return value zero in register d0.l
*
* Access this routine from within the V_INT.
* SOJ recomends that the six button driver must be called from
* within V_INT.
* The Z80 Enable/Disable code is provided as a safety check, to
* prevent unfavorable bus access. Also refer to note under mods
*
* in d1.w : port number ( 0..2 )
*
* out d0.l : for case of six pad
* d0.l= 1xxx|xxxx|xxxx|xxxx|MD,TX,TY,TZ,1,1,1,1,St,TA,TC,T B,R,L,D,U
* for case of three pad
* d0.l= 0xxx|xxxx|xxxx|xxxx|xxxx|xxxx|St,TA,TC,TB,R,L,D,U
* x denotes don't care bits
* flag bit is bit 31 in d0.l
* bit 31 = 0 i.e three button controller
* bit 31 = 1 i.e six button controller
* error (unknown controller/ nothing connected) is reported by
* d0.l = 0
*
* REGISTERS:
* registers d0 to d5 are used by this routine.
* register d1 is exclusively used for input to the routine.
* register d0 is used for output
*
* EXECUTION TIME:
* six button controller, takes 722 cycles approx 90.25usecs
* three button controller, takes 688 cycles approx 86usecs
*
************************************************** ************************************
_JOYGET6:
movem.l d1/d2/d3/d4/d5/a0,-(sp)

move.w #$100,Z80BusReq * Z80 bus request
move.w #$100,Z80Reset * Z80 reset line high (NORMAL RUN STATE)
btst.b #0,Z80BusReq * Z80 bus grant acknowledge?
bne.s *-8 * wait until bus granted
moveq #0,d0
cmp.w #$0002,d1
bhi JOYGET6_ERR
add.w d1,d1
move.l #$00a10003,a0 *joystick data port address
move.b #$40,6(a0,d1.w) *set TH = output
nop
nop
move.b #$40,(a0,d1.w) * select [ ? 1 TRG-C TRG-B R L D U ]
moveq #0,d2
move.b $00(a0,d1.w),d2 * d2 = xxxx|xxxx|? 1 TRG-C TRG-B R L D U
cmp.b #$70,d2 * checking for mouse or other handshaking device
beq JOYGET6_ERR
move.b #$00,(a0,d1.w) * select [ ? 0 START TRG-A 0 0 D U ]
lsl.w #8,d2 * d2 = ? 1 TRG-C TRG-B R L D U|0 0 0 0 0 0 0 0
move.b $00(a0,d1.w),d2 * d2 = ? 1 TRG-C TRG-B R L D U|? 0 St TRG-A 0 0 D U
cmp.b #$3f,d2 * checking for nothing connected
beq JOYGET6_ERR
move.b #$40,(a0,d1.w) * select [ ? 1 TRG-C TRG-B R L D U ]
moveq #0,d3
move.b $00(a0,d1.w),d3 * d3 = xxxx|xxxx|? 1 TRG-C TRG-B R L D U
move.b #$00,(a0,d1.w) * select [ ? 0 START TRG-A 0 0 D U ]
lsl.w #8,d3
move.b $00(a0,d1.w),d3 *d3 = ? 1 TRG-C TRG-B R L D U|? 0 St TRG-A 0 0 D U
move.b #$40,(a0,d1.w) * select [ ? 1 TRG-C TRG-B R L D U ]
moveq #0,d4
move.b $00(a0,d1.w),d4 * d4 = xxxx|xxxx|? 1 TRG-C TRG-B R L D U
move.b #$00,(a0,d1.w) * select [ ? 0 START TRG-A 0 0 0 0 ]
lsl.w #8,d4
move.b $00(a0,d1.w),d4 * d4 = ? 1 TRG-C TRG-B R L D U|? 0 St TRG-A 0 0 0 0
move.b #$40,(a0,d1.w) * select [ ? 1 0 0 MD TX TY TZ ]
moveq #0,d5
move.b $00(a0,d1.w),d5 * d5 = 0000|0000|? 1 0 0 MD TX TY TZ
move.b #$00,(a0,d1.w) * select [ ? 0 0 0 1 1 1 1 ]
lsl.w #8,d5
move.b $00(a0,d1.w),d5 * d5 = ? 1 0 0 MD TX TY TZ| ? 0 0 0 1 1 1 1
move.b #$40,(a0,d1.w)
cmp.w d2,d3
bne JOYGET6_ERR * nothing connected or unknown device
cmp.w d3,d4
beq JOYGET3_PAD * regular 3 button controller
and.w #$000f,d4
bne JOYGET6_ERR
move.b d2,d0
lsl.w #4,d0 * d0.w = 0000|? 0 St TA 0 0 D U 0 0 0 0
lsr.w #8,d2 * d2.w = 0000|0000|? 1 TC TB R L D U
move.b d2,d0 * d0.w = 0000|? 0 St TA ? 1 TC TB R L D U
lsl.b #2,d0 * d0.w = 0000|? 0 St TA TC TB R L D U 0 0
lsr.w #2,d0 * d0.w = 0000|0 0 ? 0|St TA TC TB R L D U
and.l #$000000ff,d0
lsl.b #4,d5 * d5.w = ? 1 0 0 MD TX TY TZ|1 1 1 1 0 0 0 0
lsl.w #4,d5 * d5.w = MD TX TY TZ 1 1 1 1 0 0 0 0 0 0 0 0
or.w d5,d0 * d0.w = MD TX TY TZ 1 1 1 1 St TA TC TB R L D U
or.l #$10000000,d0 * d0.l = 1xxx|xxxx|xxxx|xxxx|MD,TX,TY,TZ,St,TA,TC,TB,R,L,D, U

bra JOYGET6_ERR
JOYGET3_PAD:
move.b d2,d0
lsl.w #4,d0 * d0.w = 0000|? 0 St TA 0 0 D U 0 0 0 0
lsr.w #8,d2 * d2.w = 0000|0000|? 1 TC TB R L D U
move.b d2,d0 * d0.w = 0000|? 0 St TA ? 1 TC TB R L D U
lsl.b #2,d0 * d0.w = 0000|? 0 St TA TC TB R L D U 0 0
lsr.w #2,d0 * d0.w = 0000|0 0 ? 0|St TA TC TB R L D U
and.l #$000000ff,d0 * d0.l = 0xxx|xxxx|xxxx|xxxx|xxxx|xxxx|St,TA,TC,TB,R,L,D,U
JOYGET6_ERR:
move.w #0,Z80BusReq * Z80 bus release
movem.l (sp)+,d1/d2/d3/d4/d5/a0
rts
==========================================



Now,the main.asm is compilable by using the command line in build.bat or just "ASM68K.EXE MAIN.ASM,MAIN.BIN".

After that,you can pad the binary code with the command line in build.bat "ROMPAD MAIN.BIN 255 0" to make the ROM alien to 0xFF.And "FIXHEADR MAIN.BIN" fix the genesis checksum in header.

Now the rom is completely valid.Open it in any emulator.You will get nothing because your code does do nothing.