Jump to content
IGNORED

Port from 8-bit to 5200


peteym5

Recommended Posts

I am attempting to set up this game to assemble both the 8-bit machines and the Atari 5200. The Game will have elements from Asteroids. Current working title is Megaoids because part of the game is that you have to destroy bases in asteroids fields, or blow up the asteroids itself. Take multiple shots to blow up a mega size asteroid with a base. I am still working out the details. The 8-bit version will be geared to run on computer with 16K present (600XL, or 400 with 16K) to a 130XE. The 5200 will need to run from a 16K cartridge. Both are being set up to only use the first 16K of RAM that is common on all machines. Of course I cannot publicly display the full source code at this time. Will need to do that through private messenger and email, along with the persons word that they will not share code. It is still less than half done.

    LDX SHIPDIR
    LDA TABSIN,X
    AND #127
    ASL @
    STA M0
    LDA TABCOS,X
    AND #127
    ASL @
    STA M1 
    
    IFT CartridgeType = CartridgeStandard16K
      LDA PORTA		
  		AND #$0F		
    ELI CartridgeType = CartType520016K||CartridgeType = CartType520016K2
    
      ;Need Code for 5200 Here
    
    EIF
    
		LSR @
    TAY
    BCC THRUST_SHIP_HOZ
    JMP NOT_JOYSTICKUP
THRUST_SHIP_HOZ
    LDX SHIPDIR  
    LDA TABSIN,X
    BMI SHIP_HOZ_LEFT
    BIT SHIPDELTADR
    BVS SUB_SHIP_HOZ    
    CLC
    ADC SHIPDELTAXL
    STA SHIPDELTAXL
    BPL NO_RITE_DELTA_INC
    AND #127
    STA SHIPDELTAXL
    LDA SHIPDELTAXH
    CLC
    ADC #4
    CMP M0
    BCC NO_RITE_MAX
    LDA M0
NO_RITE_MAX
    STA SHIPDELTAXH
NO_RITE_DELTA_INC
    LDA SHIPDELTADR
    AND #191
    ORA #1
    STA SHIPDELTADR
    JMP THRUST_SHIP_VERT
SUB_SHIP_HOZ
    AND #127
    STA M2
    LDA SHIPDELTAXL
    SEC
    SBC M2
    STA SHIPDELTAXL
    BPL NO_SHIP_RITE_REV_DEC
    AND #127
    STA SHIPDELTAXL
    LDA SHIPDELTAXH
    SEC
    SBC #4  
    BCS NO_SHIP_RITE_REV_DEC
    LDA SHIPDELTADR
    AND #191
    ORA #1
    STA SHIPDELTADR
    LDA #0
NO_SHIP_RITE_REV_DEC
    STA SHIPDELTAXH            
NO_SHIP_RITE_REV   
    JMP THRUST_SHIP_VERT
SHIP_HOZ_LEFT
    AND #127
    STA M2
    BIT SHIPDELTADR
    BVC ADD_SHIP_HOZ
    CLC
    ADC SHIPDELTAXL
    STA SHIPDELTAXL
    BPL NO_LEFT_DELTA_INC
    AND #127
    STA SHIPDELTAXL        
    LDA SHIPDELTAXH
    CLC
    ADC #4
    CMP M0
    BCC NO_LEFT_MAX
    LDA M0
NO_LEFT_MAX
    STA SHIPDELTAXH

NO_LEFT_DELTA_INC
    LDA SHIPDELTADR
    ORA #65
    STA SHIPDELTADR
    JMP THRUST_SHIP_VERT
ADD_SHIP_HOZ
    LDA SHIPDELTAXL
    SEC
    SBC M2
    STA SHIPDELTAXL    
    BPL NO_SHIP_LEFT_REV_DEC
    AND #127
    STA SHIPDELTAXL
    LDA SHIPDELTAXH
    SEC
    SBC #4
    BCS NO_SHIP_LEFT_REV_DEC    
    LDA SHIPDELTADR
    ORA #65
    STA SHIPDELTADR 
    LDA #0     
NO_SHIP_LEFT_REV_DEC
    STA SHIPDELTAXH      
THRUST_SHIP_VERT 
    LDA TABCOS,X
    BPL SHIP_HOZ_UP
    BIT SHIPDELTADR
    BMI SUB_SHIP_VRT
    AND #127    
    CLC
    ADC SHIPDELTAYL
    STA SHIPDELTAYL    
    BPL NO_DOWN_DELTA_INC
    AND #127
    STA SHIPDELTAYL
    
    LDA SHIPDELTAYH
    CLC
    ADC #4
    CMP M1
    BCC NO_DOWN_MAX
    LDA M1
NO_DOWN_MAX
    STA SHIPDELTAYH
NO_DOWN_DELTA_INC
    LDA SHIPDELTADR
    AND #127
    ORA #1
    STA SHIPDELTADR
    JMP THRUST_SHIP_DONE
SUB_SHIP_VRT
    AND #127
    STA M2
    LDA SHIPDELTAYL
    SEC
    SBC M2
    STA SHIPDELTAYL
    BPL NO_SHIP_DOWN_REV
    AND #127
    STA SHIPDELTAYL
    LDA SHIPDELTAYH
    SEC
    SBC #4
    STA SHIPDELTAYH
    BCS NO_SHIP_DOWN_REV
    LDA SHIPDELTADR
    AND #127
    ORA #1
    STA SHIPDELTADR
    LDA #0        
NO_SHIP_DOWN_REV   
    STA SHIPDELTAYH
    JMP THRUST_SHIP_DONE
SHIP_HOZ_UP
    
    AND #127
    STA M2
    BIT SHIPDELTADR
    BPL ADD_SHIP_VRT
    CLC
    ADC SHIPDELTAYL
    STA SHIPDELTAYL
    BPL NO_UP_DELTA_INC
    AND #127
    STA SHIPDELTAYL
    LDA SHIPDELTAYH
    CLC
    ADC #4
    CMP M1
    BCC NO_UP_MAX
    LDA M1
NO_UP_MAX
    STA SHIPDELTAYH
NO_UP_DELTA_INC    
    LDA SHIPDELTADR
    ORA #129
    STA SHIPDELTADR
    JMP THRUST_SHIP_DONE
ADD_SHIP_VRT
    LDA SHIPDELTAYL
    SEC
    SBC M2
    STA SHIPDELTAYL
    BPL NO_SHIP_UP_REV
    AND #127
    STA SHIPDELTAYL
    LDA SHIPDELTAYH
    SEC
    SBC #4
    BCS NO_SHIP_UP_REV
    LDA SHIPDELTADR
    ORA #129  
    STA SHIPDELTADR
    LDA #0      
NO_SHIP_UP_REV
    STA SHIPDELTAYH
THRUST_SHIP_DONE

NOT_JOYSTICKUP        
    TYA
		LSR @
    TAY
    BCS NOT_JOYSTICKDOWN

NOT_JOYSTICKDOWN
    LDA PORTA
    AND #$0C
    LSR @
    LSR @
    TAX
    LDA SHIPDIR
    CLC
    ADC MINUS_PLUS_STICK,X
    CMP #240
    BCC NO_SHIPDIR71 
    LDA #71
NO_SHIPDIR71
    CMP #72
    BCC NO_SHIPDIR0 
    LDA #0
NO_SHIPDIR0
    STA SHIPDIR

    LDA SHIPDELTADR
    BEQ SHIP_NO_MOVE
    LDA SHIPYLO
    BIT SHIPDELTADR
    BPL SHIP_MOVE_DOWN
SHIP_MOVE_UP
    SEC
    SBC SHIPDELTAYH
    STA SHIPYLO
    BCS NO_SUB_YH
    DEC SHIPYHI    
NO_SUB_YH
    JMP CHECK_SHIP_HOZ
SHIP_MOVE_DOWN
    CLC
    ADC SHIPDELTAYH
    STA SHIPYLO
    BCC NO_ADD_YH
    INC SHIPYHI    
NO_ADD_YH

CHECK_SHIP_HOZ
    LDA SHIPXLO
    BIT SHIPDELTADR
    BVC SHIP_MOVE_LEFT
SHIP_MOVE_RIGHT
    SEC
    SBC SHIPDELTAXH
    STA SHIPXLO
    BCS NO_SUB_XH
    DEC SHIPXHI    
NO_SUB_XH
    JMP SHIP_NO_MOVE
SHIP_MOVE_LEFT
    CLC
    ADC SHIPDELTAXH
    STA SHIPXLO
    BCC NO_ADD_XH
    INC SHIPXHI    
NO_ADD_XH

SHIP_NO_MOVE
  
    



    LDA FIREAGAIN
    BEQ NO_FIREAGAIN_DEC
    DEC FIREAGAIN
NO_FIREAGAIN_DEC

		IFT CartridgeType = CartridgeStandard16K
      LDA TRIG0    
      BEQ PRESSING_FIRE
    ELI CartridgeType = CartType520016K||CartridgeType = CartType520016K2
       ;Need Code for 5200 Here
    EIF    
    JMP DO_FIRE_RESET
PRESSING_FIRE    
    
    LDA FIREAGAIN
    BEQ ALLOW_BOLT_FIRE
    JMP NO_FIRE_RESET
    
ALLOW_BOLT_FIRE
    LDA #2
    STA M0

BOLT_AGAIN_LOOP    
    LDY FIREBOLTNUM
    INY 
    CPY #3
    BCC NOFIREBOLT0    
    LDY #0
NOFIREBOLT0    
    STY FIREBOLTNUM
    
    LDA BOLTSTATUS,Y
    BEQ FIRE_THIS_BOLT
    DEC M0
    BNE BOLT_AGAIN_LOOP
    JMP NO_FIRE_RESET
FIRE_THIS_BOLT
    LDA #32
    STA BOLTSTATUS,Y
        
    LDA SHIPDIR
    TAX
    CMP #36
    BCC NOBOLTHLF
    SBC #36
NOBOLTHLF
    CLC
    ADC #74
    STA BOLTIM,Y

    STA BOLTDIR
      
    LDA SHIPXHI
    STA BOLTSX,Y
    LDA SHIPYHI
    STA BOLTSY,Y
    
    LDA TABSIN,X
    AND #127
    STA BOLTDXL,Y
    ;STA M0
    LDA BLTSIN,X
    STA BOLTDXH,Y
Edited by peteym5
Link to comment
Share on other sites

Thinking back, the main things I needed to do were:

 

1. Define an assembler flag to pick which system you're building for.

2. Include one of 2 files to define the register name/locations

3. Ditto for vectors and any other RAM functions the systems have in common

4. If you need any OS function not provided in the 5200, you need to have an equivalent routine to assemble into the 5200 build

(MULE used floating point, so my 5200 build included support for it)

5. Write 2 routines to handle sticks and other inputs and include the one you need.

 

Umm.. that's about it except for small data sections to make the cartridge init stuff work.

  • Like 1
Link to comment
Share on other sites

Never actually had a chance to code on the real hardware, but I've seen more than enough in emulation already:

  • The 5200 OS does not clear RAM. Make sure you do so explicitly.
  • Be careful with DLI timing. The 5200 OS has an extra STA NMIRES prior to calling through (VDSLST), which has been problematic on ports of 8-bit games with DLI handlers that have tight stage 1 timing.
  • Decimal mode is not cleared before invoking the VBI handler.
  • Only CRITIC is checked by VBI, not the I flag. If you have code bracketed with SEI/CLI to guard changes to shadow variables or to temporarily shield changes from the deferred VBI, you'll need to modify it to use INC CRITIC/DEC CRITIC.
  • The 5200 joysticks require keyboard debounce to be off to read the keypads. If you write SKCTL=$03 instead of $02, the keypads will not work. Similarly, SKSTAT bit 2 also acts differently and will pulse about 7 times a frame for a held button. Not all emulators emulate this.
  • Like 2
Link to comment
Share on other sites

Some aspects of processing like VBlank and controller input handling are so different that IMO it'd be better to just have entirely seperate conditional assembly of such routines.

 

Also, that printer effect listing is impossible to read with the "deflection" theme (dk grey) that I'm using.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

I have figured out some memory layout for the cartridges and what RAM locations used by the 5200 in Page 0 and Page 2. I can actually discard my own custom Real Time Clock code because many of my ML games bypass the 8-bit OS VBIs, NMI, and DLI routines. I discovered there are 2 16K cartridge memory layouts for the 5200. The One 16K chip version is mapped from $8000 to $BFFF just as the 8-bit counter part. The two chip one is a little trickier to program. Has 1st chip $4000 to $5FFF then repeated $6000 to $7FFF, then 2nd chip mapped from $8000 to $9FFF and repeated $A000 to $BFFF. What I had to do is insert extra "ORG" directive after the last RTS right before $A000 to make sure a routine does not cross a boundary. A few things had to be re-sorted.

 

We are working on figuring out reading the 5200 controllers. I know there was a few after market joystick made by 3rd parties. Was the self-centering issue ever solved?

Link to comment
Share on other sites

Well I managed to get the title screen up for Delta Space Arena on the Atari 5200 in the emulator. None of the console buttons are working yet. The 5200 immediate ROM VBI is much shorter than the 8-bit version and uses 0 page locations for shadows, so I don't have to bypass it and duplicate the function of the real-time clock. I use many DLIs so shadow color registers are not used much.

 

I have someone helping me with reading the controller and having it control things in the game.

post-14332-0-78476000-1497033289.jpg

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

I am in the process of porting the 8 planned 16K games that I made for the Atari 8-bit computer. Amok Bots, Delta Space Arena, Laser Blast, Megaoids had already been released for the 8-bit. 4 more games will be released within a year. All these were geared toward being played on a 16K computer, although 99% of owners have 64K machines. That was to make sure the games could one day be ported to the 5200. I am also doing my own port of the 5200 Venture. I was disturbed that a hacker took our names were taken off the credits. Secretum Labyrinth Kings Gold is also being considered.

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...