PDA

View Full Version : 68K source



NexusEnix
11-20-2010, 08:13 AM
Hi,

I am using a 68k assembly program (Easy 68K) so I can start learning and exploring the language and hopefully begin to understand more about coding for the M68k, maybe making some basic demo's for the Megadrive. My question is this. How would I convert the source code into sometime that could be read by an emulator. Also is there a specific syntax for the Motorola 68000 or is it generic among the range of processors.

Thanks for your time.:-)

Piratero
11-21-2010, 05:13 AM
You need an assembler. That the Megadrive might have a special header. You'll need to either find a program to inject that header or write one yourself.

TmEE
11-22-2010, 09:45 AM
Write your code, assemble... that's how easy it it.

There is a header, but its not mandatory, except for the vector table.

DC.x is your friend when it comes to the header :P


DC.L $00FFFFFE, CodeStart, Bus_Error, AddrError
DC.L Illg_Inst, DivByZero, CHK___int, TRAPV_int
DC.L Priv_Viol, TRACE_int, LineA_emu, LineF_emu
DC.L Interrupt, Interrupt, Interrupt, Interrupt
DC.L Interrupt, Interrupt, Interrupt, Interrupt
DC.L Interrupt, Interrupt, Interrupt, Interrupt
DC.L NMI______, IntLevel1, Ext___int, IntLevel3
DC.L HBlankInt, IntLevel5, VBlankInt, IntLevel7
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 TRAP___00, TRAP___01, TRAP___02, TRAP___03
DC.L TRAP___04, TRAP___05, TRAP___06, TRAP___07
DC.L TRAP___08, TRAP___09, TRAP___10, TRAP___11
DC.L TRAP___12, TRAP___13, TRAP___14, TRAP___15
DC.B "SEGA MEGA DRIVE " ; System name
DC.B "(C)TmEE co. 2007" ; Copyright [2007.FEB -> 200*.***]
DC.B "Mj„ulane CA - kuradi kasutu alfa !!! " ; Name (local)
DC.B "CA the meowian - damn useless alpha !!! " ; Name (int.)
DC.B "GM T-000014-00" ; Type, mfgr.ID-Serial-Version
DC.W $0000 ; Checksum
DC.B "J " ; I/O support
DC.L $00000000, $0002FFFF ; ROM start->end
DC.L $00FF0000, $00FFFFFF ; RAM start->end, why ???
DC.B "RA", %11111000, $20 ; External RAM info
DC.L $00200001, $002001FF ; External RAM start->end
DC.B "No modem... " ; Modem shit
DC.B "(8<| - Dark side of the Force rules !!! " ; Whatever
DC.B "E like Estonia " ; Regions

(is here a code tag...? standard formatting ruins everything here... especially spaces)

NexusEnix
11-22-2010, 09:46 AM
@Piratero: Oh, okay, I think I know what you mean thank you for your help.

@TmEE: Awesome! That's just what I needed to know. Thank you very much.

segaloco
11-24-2010, 02:51 AM
Oh TmEE~

Anyway, for a bit more than he put there



dc.l StackStart, EntryPoint, BusErr, AddressErr
dc.l IllegalInstr, ZeroDiv, CHKInstr, TRAPVInstr
dc.l PrivViol, Trace, Line1010, Line1111
dc.l 0, 0, 0, UninitIntVec
dc.l 0, 0, 0, 0
dc.l 0, 0, 0, 0
dc.l SpInit, Level1, ExtInt, Level3
dc.l HInt, Level5, VInt, Level7
dc.l Trap0, Trap1, Trap2, Trap3
dc.l Trap4, Trap5, Trap6, Trap7
dc.l Trap8, Trap9, TrapA, TrapB
dc.l TrapC, TrapD, TrapE, TrapF
dc.l 0, 0, 0, 0
dc.l 0, 0, 0, 0
dc.l 0, 0, 0, 0
dc.l 0, 0, 0, 0
dc.b "SEGA MEGA DRIVE " ; Or SEGA GENESIS, must be 16 chars
dc.b "(C)SEGA 1998.MAR" ; (C)SEGA or (C)T-XX YEAR.MON (Or whatever you want, must be 16 chars though :P)
dc.b "THIS IS AN EXAMPLE OF A DOMESTIC TITLE (JAPAN) " ; Domestic (Asian) title, 48 chars (can be Shift-JIS)
dc.b "THIS IS AN EXAMPLE OF AN INTERNATIONAL TITLE " ; International (Overseas) title, 48 chars (can be Shift-JIS...but why? :v)
dc.b "GM XXXXXXXX-XX" ; Game code (GM for game, AI for educational, and BR for bootrom (Sega CD, 32X only), whee educational games
; Can also be of the form MKXXXX -XX where XXXXXXXX-XX is, must be 14 chars
dc.w $BEEF ; Checksum
dc.b 'J ' ; I'll explain this more in the post... (Must be 16 chars)
dc.l 0, RomEnd-1 ; Put RomEnd: at the end of your code
dc.l $FF0000, $FFFFFF ; This is ram, this is constant unless you do weird stuff
dc.b ' ', %00100000, %00100000 ; I'll explain this in the post too
dc.l $20202020, $20202020 ; Set to the bounds of external ram (usu $00200000-$something)
dc.b ' ', ' ', ' ' ; 'MO' for modem support, then 'xxxx' company name, 'yy.x' modem number.version (must be 2 char, 4char, 4char)
dc.b ' ' ; "memo" section, 40 chars
dc.b 'JUE ' ; region codes, will list in post (16 chars)
(doesn't display all spaces :dammit:)

Okay, that first one I said, the dc.b 'J ' are supported devices (in any order):

J = Joystick (Standard controllers)
0 = Joystick for MS
K = Keyboard
R = SERIAL (RS232C)
P = Printer
T = Tablet
B = Control Ball
V = Paddle Controller
F = FDD (Floppy Disks)
C = CD (Sega CD :P)
M = Mouse
6 = 6 Button Pad
4 = Multi-tap


Okay, the line dc.b ' ', %0010000, %00100000:

In the ' ' put RA to enable external RAM
First bit in the format %1x1yz000
x = 1 if Backup (SRAM) and 0 if Not backup (EXTERNAL RAM)
yz = 10 for even addr, 11 for odd adr, 00 for both

Now for the region codes:
J = Asia, NTSC (Japan)
E = Overseas, PAL (Europe)
U = Overseas, NTSC (USA)
0 = No region (As in none supported...why this exists..no clue)
1 = Asia, NTSC (Japan)
2 = Asia, PAL (China???)
3 = Asia, NTSC and Asia, PAL (Japan and (China???))
4 = Overseas, NTSC (USA)
5 = Asia, NTSC and Overseas, NTSC (Japan and USA)
6 = Asia, PAL and Overseas, NTSC ((China???) and USA)
7 = Asia, NTSC, Asia, PAL, and Overseas, NTSC (Japan, (China???), and USA)
8 = Overseas, PAL (Europe)
9 = Asia, NTSC and Overseas, PAL (Japan and Europe)
A = Asia, PAL and Overseas, PAL ((China???) and Europe)
B = Asia, NTSC, Asia, PAL, and Overseas PAL (Japan, (China???), and Europe)
C = Overseas, NTSC and Overseas, PAL (USA and Europe)
D = Asia, NTSC, Overseas, NTSC, and Overseas, PAL (Japan, USA, and Europe)
E = Asia, PAL, Overseas, NTSC, and Overseas, PAL ((China???), USA, and Europe)
F = All of them (really didn't feel like typing all that out :P)

Edit: Oh, and to suggest an assembler, either SNASM68K or ASM68K are usually suggested for newbies. (asmx, if you can compile it, is pretty good too. If you read the docs you can see that it supports embedding different architectures of code in stuff, so you can embed your z80 code in your 68000 code if you plan on using the z80, and then assemble it in one sweep instead of incbin crap :P)

Edit2: Oh, and if you go with asmx, ABSOLUTELY DON'T FORGET TO ALWAYS PASS -b 0 as an option. If you don't it generates S-Records in 68k mode, which is annoying :v

Edit3: Added one more identifier to serial code. BR is used internally for bootroms like the Sega CD bios and the 68k 32X bios.

NexusEnix
11-24-2010, 03:33 PM
@segaloco Awesome stuff thanks, very helpful. I will try and implement that code and I will give those assemblers a try to.:dance:

segaloco
11-25-2010, 09:20 PM
http://gilgalad.arc-nova.org/nes-source/Barry%20Leitch/Genesis/SOURCE/ICD_BLK4.S

This also might help you. I don't necessarily mean for you to use that specifically, but there are a couple of things in there you should do, namely the security check (sending 'SEGA' to $A14000)



move.b -$10FF(a1), d0
andi.b #$F, d0
beq.s SkipSecurity
move.l #'SEGA', $2F00(a1)

SkipSecurity:

NexusEnix
11-26-2010, 09:06 AM
Great stuff thanks again!

I'm currently reading through the M68k Programmer Reference Manual and I have an essay to write, so it will be a few days till I start coding again. But this is very helpfull and I will give it a go after I'm done.:-)