xucaen Posted October 20, 2015 Share Posted October 20, 2015 I am trying to learn what is the basic required code for every 7800 program. I can't seem to make heads nor tails out of the source code I was able to find. So I would like to try a different approach. A long time ago, I started getting into 2600 programming. Back then, and I think today, there were two files called macro.h and vcs.h that you would include at the top of your program. I am attaching a sample I had made years ago. I am sure everyone had started this way. But for now, I am not interested in doing 2600 programs on the 7800. The attached is only a sample of a 2600 program I made and want to translate it into a 7800 program. . I think there must be code that goes into every 7800 program - steps that are done for every 7800 game. So I would like to ask: How would I make this same sample as a 7800 program? Here are the files I had downloaded as part of a "7800 dev kit". How would I use these to create a simple sample like the ball1.asm I attached? ball1.asm Quote Link to comment Share on other sites More sharing options...
SIO2 Posted October 20, 2015 Share Posted October 20, 2015 Just a suggestion but if you have any understanding of Basic, you might take a look at 7800bas. There are several demos included with it and at least a couple game sources are available including my Shoot the U.F.O. 2015 source. When you compile a 7800bas program, it also generates an assembly listing which I think you may find educational. Plus, you can include inline assembly into 7800bas programs if you wish. Quote Link to comment Share on other sites More sharing options...
xucaen Posted October 21, 2015 Author Share Posted October 21, 2015 Just a suggestion but if you have any understanding of Basic, you might take a look at 7800bas. There are several demos included with it and at least a couple game sources are available including my Shoot the U.F.O. 2015 source. When you compile a 7800bas program, it also generates an assembly listing which I think you may find educational. Plus, you can include inline assembly into 7800bas programs if you wish. My goal is learn 7800 programming in 6502 assembler. I know 6502 somewhat already so I don't want to have to learn something else on top of the 7800 hardware. If anyone can help me I would greatly appreciate it. I am trying to figure out how to apply the a78header.asm, since I am running 64 bit windows, the a78hdr.exe won't run. A simple 7800 example, as in my 2600 ball1.asm, would be greatly appreciated. Just FYI, I have 20 years experience in object oriented application programming, working exclusively with C# since 2001. I started learning 6502 back in 2005 and I wrote a bunch of samples as I learned the hardware but haven't really touched it since 2006. About a year or 2 ago I started looking into Jaguar and 7800 programming. The Jaguar has a steeper learning curve for me, so I would like to learn the 7800 using 6502 assembly. Last week, CPUWiz gave the the link to some 7800 source code, but after assembling the code, I can't get it to run on EMU7800, and I can't even get MESS to work at all. For the sake of comparison, I was able to assemble my 2600 samples and run them in Stella. I really want to be able to do that with the 7800. I guess you could say that my dream is to write a game for the 7800 and give it to Atari Age to sell on the store. if I can get working samples to build and run in EMU7800 I think I'm about a year out from starting development on an actual game. I really don't want to give this up again. Quote Link to comment Share on other sites More sharing options...
xucaen Posted October 21, 2015 Author Share Posted October 21, 2015 In trying to understand the required code, it would seem that the a78header is only necessary for emulators. If I were to build my samples to play directly on 7800 hardware, would I not need the header? The a78sign.exe tool is confusing to me. I do understand that it is needed to make the 7800 game playable as a 7800 game, but the thing I don't understand it the distinction it makes between .bin and .a78 files. When I build my source without the header (because I haven't figured out where to put it yet), and I call it a .bin file, the a78sign.exe says "Signature Invalid - Wrote valid signature". Does that mean it will now run on 7800 hardware? But if I call the file a .a78, a78sign.exe says "File is not in .a78 format". Does a78sign.exe look for a header and if it isn't there is fails? Does this also mean .a78 extension should only be used for emulator games? And what do I do when I want to run on real hardware? I have to remove the header, change the extension, re-run a78sign.exe and hope for the best? based on this, I have deduced that: Emulators require there be a special header, the file extension must be .a78 and it must be signed as an .a78 file. 7800 hardware does not require a special header, the file extension must be .bin and it must be signed as a .bin file. Is that correct? Quote Link to comment Share on other sites More sharing options...
SIO2 Posted October 21, 2015 Share Posted October 21, 2015 (edited) 7800bas takes care of all that. It signs the file an spits out a .bin and an .a78 version. So, I don't know how to do it the way you want to. Hopefully someone here will be able to help you. I only use 6502 assembly for small routines that I use within Basic programs. Then, I only use it if the program requires more speed. I have not needed to use assembly with 7800bas since it is so efficient. I have read though that the .bin and the .a78 are identical except the .a78 has the header which contains the info the emulator needs. I believe that, if you strip the header off an .a78 you can make a .bin that plays on real hardware. Good luck. Looking forward to seeing your 7800 game. Edited October 21, 2015 by SIO2 Quote Link to comment Share on other sites More sharing options...
xucaen Posted October 21, 2015 Author Share Posted October 21, 2015 Ok, so the header is necessary for emulators and not necessary for real hardware. Now the next problem I am facing is - where in the source do I insert the header? I have tried inserting the header into different places within the source code, but it never runs on emulator. So, either I just haven't hit on the right place to put it, or the header doesn't really work, or the emulator doesn't work. I am attaching my ball1.asm again, this time with header and I am building a .a78 file. The .a78 file does not run on emulator. ball1.asm ball1.a78 Quote Link to comment Share on other sites More sharing options...
xucaen Posted October 21, 2015 Author Share Posted October 21, 2015 Then I thought maybe my ROM needs to start at $8000 instead of $F000, so I changed it. It builds, but doesn't run. I get the same error as above. ball1.a78 ball1.asm Quote Link to comment Share on other sites More sharing options...
MobiusAqua Posted October 21, 2015 Share Posted October 21, 2015 The header should go at the top of the A78 file. It should be the first 128 bytes, exactly. Your program code would go under the line "ACTUAL CART DATA STARTS HERE", if I remember right. Quote Link to comment Share on other sites More sharing options...
xucaen Posted October 21, 2015 Author Share Posted October 21, 2015 The header should go at the top of the A78 file. It should be the first 128 bytes, exactly. Your program code would go under the line "ACTUAL CART DATA STARTS HERE", if I remember right. When I tried that I got errors. source\ball1.asm (1): error: Unknown Mnemonic '6502'. source\ball1.asm (57): error: Unknown Mnemonic 'ldx'. source\ball1.asm (58): error: Unknown Mnemonic 'lda'. source\ball1.asm (59): error: Unknown Mnemonic 'sta'. source\ball1.asm (60): error: Unknown Mnemonic 'inx'. source\ball1.asm (61): error: Unknown Mnemonic 'bne'. source\ball1.asm (68): error: Unknown Mnemonic 'lda'. source\ball1.asm (69): error: Unknown Mnemonic 'sta'. source\ball1.asm (81): error: Unknown Mnemonic 'lda'. source\ball1.asm (81): error: Unknown Mnemonic 'sta'. source\ball1.asm (81): error: Unknown Mnemonic 'sta'. source\ball1.asm (81): error: Unknown Mnemonic 'lsr'. source\ball1.asm (81): error: Unknown Mnemonic 'bne'. source\ball1.asm (88): error: Unknown Mnemonic 'ldx'. source\ball1.asm (90): error: Unknown Mnemonic 'sta'. source\ball1.asm (91): error: Unknown Mnemonic 'dex'. source\ball1.asm (92): error: Unknown Mnemonic 'bne'. source\ball1.asm (94): error: Unknown Mnemonic 'nop'. source\ball1.asm (94): error: Unknown Mnemonic 'nop'. source\ball1.asm (94): error: Unknown Mnemonic 'nop'. source\ball1.asm (94): error: Unknown Mnemonic 'nop'. source\ball1.asm (94): error: Unknown Mnemonic 'nop'. source\ball1.asm (94): error: Unknown Mnemonic 'nop'. source\ball1.asm (94): error: Unknown Mnemonic 'nop'. source\ball1.asm (94): error: Unknown Mnemonic 'nop'. source\ball1.asm (95): error: Unknown Mnemonic 'nop'. source\ball1.asm (95): error: Unknown Mnemonic 'nop'. source\ball1.asm (95): error: Unknown Mnemonic 'nop'. source\ball1.asm (95): error: Unknown Mnemonic 'nop'. source\ball1.asm (95): error: Unknown Mnemonic 'nop'. source\ball1.asm (95): error: Unknown Mnemonic 'nop'. source\ball1.asm (95): error: Unknown Mnemonic 'nop'. source\ball1.asm (95): error: Unknown Mnemonic 'nop'. source\ball1.asm (95): error: Unknown Mnemonic 'nop'. source\ball1.asm (95): error: Unknown Mnemonic 'nop'. source\ball1.asm (96): error: Unknown Mnemonic 'sta'. source\ball1.asm (98): error: Unknown Mnemonic 'LDX'. source\ball1.asm (99): error: Unknown Mnemonic 'STX'. source\ball1.asm (100): error: Unknown Mnemonic 'sta'. source\ball1.asm (109): error: Unknown Mnemonic 'ldx'. source\ball1.asm (121): error: Unknown Mnemonic 'CPX'. source\ball1.asm (122): error: Unknown Mnemonic 'BEQ'. source\ball1.asm (123): error: Unknown Mnemonic 'JMP'. source\ball1.asm (126): error: Unknown Mnemonic 'lda'. source\ball1.asm (129): error: Unknown Mnemonic 'sta'. source\ball1.asm (130): error: Unknown Mnemonic 'STA'. source\ball1.asm (131): error: Unknown Mnemonic 'DEX'. source\ball1.asm (133): error: Unknown Mnemonic 'lda'. source\ball1.asm (134): error: Unknown Mnemonic 'sta'. source\ball1.asm (135): error: Unknown Mnemonic 'sta'. source\ball1.asm (136): error: Unknown Mnemonic 'DEX'. source\ball1.asm (137): error: Unknown Mnemonic 'BNE'. source\ball1.asm (148): error: Unknown Mnemonic 'LDX'. source\ball1.asm (150): error: Unknown Mnemonic 'STA'. source\ball1.asm (151): error: Unknown Mnemonic 'DEX'. source\ball1.asm (152): error: Unknown Mnemonic 'BNE'. source\ball1.asm (160): error: Unknown Mnemonic 'JMP'. Unrecoverable error(s) in pass, aborting assembly! Quote Link to comment Share on other sites More sharing options...
xucaen Posted October 21, 2015 Author Share Posted October 21, 2015 I stripped everything out and got this to build with header, but still doesn't run in the emulator. bare.asm Quote Link to comment Share on other sites More sharing options...
SIO2 Posted October 21, 2015 Share Posted October 21, 2015 Not sure if this will help any but looking at the Shoot the U.F.O. 2015 .asm file it starts with what looks to me like an Atarivox driver then the following code then my game source code. processor 6502 ;include "macro.h" include "7800basic.h" include "7800basic_variable_redefs.h" ;start address of cart... ifconst ROM48k ORG $4000 else ifconst bankswitchmode ORG $8000 RORG $8000 else ORG $8000 endif endif game 1 Quote Link to comment Share on other sites More sharing options...
Roy Posted October 21, 2015 Share Posted October 21, 2015 (edited) Just for giggles, try this at the bottom of the assembly: .byte $FF ;Region verification .byte $47 ;ROM start $4000 .word NMI .word START .word IRQ Where the NMI, START, and IRQ point to addresses with the same name. I'm not sure if the emulators require it, but you need to also initialize the 7800 at the START label. As you may know, the 6502 on startup looks for these vectors at the bottom of ROM. ex: START: sei ;Disable interrupts cld ;Clear decimal mode ;Atari recommended start-up procedure lda #$07 sta INPTCTRL ;Lock into 7800 mode lda #$7F sta CTRL ;Disable DMA lda #$00 sta OFFSET sta INPTCTRL ldx #$FF ;Reset stack pointer txs;INSERT CLEAR RAM CODE HEREloop: jmp loop NMI: RTI IRQ: RTI Excluding code to clear ram, this may be all you need plus the header. Hope this helps some, I'm by no means an expert. Oh, and be sure to also have the hardware addresses defined: INPTCTRL = $01 ;Input controlAUDC0 = $15 ;Audio Control Channel 0AUDC1 = $16 ;Audio Control Channel 1AUDF0 = $17 ;Audio Fr=ency Channel 0AUDF1 = $18 ;Audio Fr=ency Channel 1AUDV0 = $19 ;Audio Volume Channel 0AUDV1 = $1A ;Audio Volume Channel 1INPT0 = $08 ;Paddle Control Input 0INPT1 = $09 ;Paddle Control Input 1INPT2 = $0A ;Paddle Control Input 2INPT3 = $0B ;Paddle Control Input 3INPT4 = $0C ;Player 0 Fire Button InputINPT5 = $0D ;Player 1 Fire Button Input ;Maria equates BACKGRND = $20 ;Background ColorP0C1 = $21 ;Palette 0 - Color 1P0C2 = $22 ;Palette 0 - Color 2P0C3 = $23 ;Palette 0 - Color 3WSYNC = $24 ;Wait For SyncP1C1 = $25 ;Palette 1 - Color 1P1C2 = $26 ;Palette 1 - Color 2P1C3 = $27 ;Palette 1 - Color 3MSTAT = $28 ;Maria StatusP2C1 = $29 ;Palette 2 - Color 1P2C2 = $2A ;Palette 2 - Color 2P2C3 = $2B ;Palette 2 - Color 3DPPH = $2C ;Display List List Pointer HighP3C1 = $2D ;Palette 3 - Color 1P3C2 = $2E ;Palette 3 - Color 2P3C3 = $2F ;Palette 3 - Color 3DPPL = $30 ;Display List List Pointer LowP4C1 = $31 ;Palette 4 - Color 1P4C2 = $32 ;Palette 4 - Color 2P4C3 = $33 ;Palette 4 - Color 3CHARBASE = $34 ;Character Base AddressP5C1 = $35 ;Palette 5 - Color 1P5C2 = $36 ;Palette 5 - Color 2P5C3 = $37 ;Palette 5 - Color 3OFFSET = $38 ;Unused - Store zero hereP6C1 = $39 ;Palette 6 - Color 1P6C2 = $3A ;Palette 6 - Color 2P6C3 = $3B ;Palette 6 - Color 3CTRL = $3C ;Maria Control RegisterP7C1 = $3D ;Palette 7 - Color 1P7C2 = $3E ;Palette 7 - Color 2P7C3 = $3F ;Palette 7 - Color 3 ;Console Equates SWCHA = $280 ;P0, P1 Joystick Directional InputSWCHB = $282 ;Console SwitchesCTLSWA = $281 ;I/O Control for SCHWACTLSWB = $283 ;I/O Control for SCHWB (sorry, not sure how to use spoilers.) Edited October 21, 2015 by Roy 1 Quote Link to comment Share on other sites More sharing options...
iesposta Posted October 21, 2015 Share Posted October 21, 2015 I just wanted to add that my 7800 emulation, through Prosystem in Retroarch, only loads .bin 7800 files. If I remove the top 128 bytes from an .a78 file and rename it .bin it works. Luckily, people usually post both types of files. Sorry I can't help with programming questions. 1 Quote Link to comment Share on other sites More sharing options...
xucaen Posted October 22, 2015 Author Share Posted October 22, 2015 I got mame64 working. Once I figured out where it was looking for the bios and .ini I was able to get it to run my sample. My next steps: figure out how to display sprites. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.