Jump to content
IGNORED

required code for every 7800 program - need help understanding.


xucaen

Recommended Posts

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?

7800_dev_kit.png

ball1.asm

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 by SIO2
Link to comment
Share on other sites

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.

 

emu7800_error.png

ball1.asm

ball1.a78

Link to comment
Share on other sites

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!
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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 HERE

loop:
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. :D Oh, and be sure to also have the hardware addresses defined:

INPTCTRL = $01 ;Input control
AUDC0 = $15 ;Audio Control Channel 0
AUDC1 = $16 ;Audio Control Channel 1
AUDF0 = $17 ;Audio Fr=ency Channel 0
AUDF1 = $18 ;Audio Fr=ency Channel 1
AUDV0 = $19 ;Audio Volume Channel 0
AUDV1 = $1A ;Audio Volume Channel 1
INPT0 = $08 ;Paddle Control Input 0
INPT1 = $09 ;Paddle Control Input 1
INPT2 = $0A ;Paddle Control Input 2
INPT3 = $0B ;Paddle Control Input 3
INPT4 = $0C ;Player 0 Fire Button Input
INPT5 = $0D ;Player 1 Fire Button Input
;Maria equates
BACKGRND = $20 ;Background Color
P0C1 = $21 ;Palette 0 - Color 1
P0C2 = $22 ;Palette 0 - Color 2
P0C3 = $23 ;Palette 0 - Color 3
WSYNC = $24 ;Wait For Sync
P1C1 = $25 ;Palette 1 - Color 1
P1C2 = $26 ;Palette 1 - Color 2
P1C3 = $27 ;Palette 1 - Color 3
MSTAT = $28 ;Maria Status
P2C1 = $29 ;Palette 2 - Color 1
P2C2 = $2A ;Palette 2 - Color 2
P2C3 = $2B ;Palette 2 - Color 3
DPPH = $2C ;Display List List Pointer High
P3C1 = $2D ;Palette 3 - Color 1
P3C2 = $2E ;Palette 3 - Color 2
P3C3 = $2F ;Palette 3 - Color 3
DPPL = $30 ;Display List List Pointer Low
P4C1 = $31 ;Palette 4 - Color 1
P4C2 = $32 ;Palette 4 - Color 2
P4C3 = $33 ;Palette 4 - Color 3
CHARBASE = $34 ;Character Base Address
P5C1 = $35 ;Palette 5 - Color 1
P5C2 = $36 ;Palette 5 - Color 2
P5C3 = $37 ;Palette 5 - Color 3
OFFSET = $38 ;Unused - Store zero here
P6C1 = $39 ;Palette 6 - Color 1
P6C2 = $3A ;Palette 6 - Color 2
P6C3 = $3B ;Palette 6 - Color 3
CTRL = $3C ;Maria Control Register
P7C1 = $3D ;Palette 7 - Color 1
P7C2 = $3E ;Palette 7 - Color 2
P7C3 = $3F ;Palette 7 - Color 3
;Console Equates
SWCHA = $280 ;P0, P1 Joystick Directional Input
SWCHB = $282 ;Console Switches
CTLSWA = $281 ;I/O Control for SCHWA
CTLSWB = $283 ;I/O Control for SCHWB

(sorry, not sure how to use spoilers.)

 

Edited by Roy
  • Like 1
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...