Jump to content



1

Which interrupt isn't required?


6 replies to this topic

#1 Primordial Ooze OFFLINE  

Primordial Ooze

    Dragonstomper

  • 504 posts
  • Quacker Blaster Lead Programmer
  • Location:United States of America

Posted Thu Sep 22, 2011 7:31 PM

I remember that one of the three interrupts, weren't required when creating Atari 2600 games. In addition you could save a byte by not including that interrupt and changing the starting the interrupt address at $FFFC instead of $FFFA. Could someone please tell me which interrupt i don't need and can remove safely? Any assistance in this matter would be greatly appreciated.

Sincerely,

Primordial Ooze

Edited by Primordial Ooze, Thu Sep 22, 2011 7:31 PM.


#2 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,545 posts
  • Location:Georgia, USA

Posted Thu Sep 22, 2011 10:56 PM

The three 6502 vector addresses are the NMI vector at $FFFA and $FFFB, the reset vector at $FFFC and $FFFD, and the IRQ vector at $FFFE and $FFFF. The 6507 doesn't have pins for the NMI and IRQ signals, so technically the only vector you truly need to use in your 2600 programs is the reset vector at $FFFC and $FFFD, and you don't need to include the SEI command in your startup routine. But the IRQ vector is used by the BRK command, so you can either point the IRQ vector at $FFFE and $FFFF to the same address as the reset vector (so your program will essentially reboot itself if it encounters a BRK instruction), or you can point the IRQ address to a routine that will handle the BRK interrupt and then return back to where it was called from. I don't remember which game(s) did this, but at least one game did use BRK interrupts to play different sounds.

#3 SmileyDude OFFLINE  

SmileyDude

    Chopper Commander

  • 213 posts
  • 6502 Hacker
  • Location:Wilmington, MA

Posted Wed Sep 28, 2011 8:02 PM

I came to the same conclusion about the SEI instruction, but then I came across this comment in macro.h:

;-------------------------------------------------------------------------------
; CLEAN_START
; Original author: Andrew Davie
; Standardised start-up code, clears stack, all TIA registers and RAM to 0
; Sets stack pointer to $FF, and all registers to 0
; Sets decimal mode off, sets interrupt flag (kind of un-necessary)
; Use as very first section of code on boot (ie: at reset)
; Code written to minimise total ROM usage - uses weird 6502 knowledge :)

Does anyone know what Andrew meant by "kind of un-necessary"? I just assumed that it was always un-necessary on the 6507 since both interrupts lines are tied to ground and therefore, it's impossible for an interrupt to go off. Unless there is some weird edge condition that I wasn't aware of that could cause an interrupt.

#4 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,545 posts
  • Location:Georgia, USA

Posted Thu Sep 29, 2011 8:37 PM

View PostSmileyDude, on Wed Sep 28, 2011 8:02 PM, said:

Does anyone know what Andrew meant by "kind of un-necessary"? I just assumed that it was always un-necessary on the 6507 since both interrupts lines are tied to ground and therefore, it's impossible for an interrupt to go off. Unless there is some weird edge condition that I wasn't aware of that could cause an interrupt.
Andrew would need to confirm, but I think he just meant it's unnecessary on the 2600/6507. I'm not sure about on the 7800/6502. It's only a 1-byte instruction, so it's common to just include it, whether or not it actually matters.

#5 RevEng OFFLINE  

RevEng

    River Patroller

  • 2,010 posts
  • bit shoveler
  • Location:Canada

Posted Fri Sep 30, 2011 6:24 AM

Omegamatrix used the interrupt flag as an extra bit for his Starmaster 2-button hack. I confirmed that it ran without issue on my 7800, so it appears that a 7800 running in 2600 mode ignores the state of the interrupt flag.

#6 SmileyDude OFFLINE  

SmileyDude

    Chopper Commander

  • 213 posts
  • 6502 Hacker
  • Location:Wilmington, MA

Posted Fri Sep 30, 2011 6:54 AM

I took at look at a disassembly of the 7800 BIOS, and it looks like the interrupt mode is disabled at the start and is never re-enabled by the BIOS ever.

http://atarihq.com/d...es/7800bios.asm

The only source of interrupts on the 7800 is the IRQ on the cartridge port, so for a pure 2600 game, skipping SEI shouldn't cause a problem on any system that Atari shipped. But as said above, it's a cheap form of insurance and who knows if someone will make a new version of the 2600/7800 that does use interrupts in some interesting way.

#7 Thomas Jentzsch OFFLINE  

Thomas Jentzsch

    Thrust, Jammed, SWOOPS!

  • 16,745 posts
  • Always left from right here!
  • Location:Düsseldorf, Germany

Posted Fri Oct 7, 2011 9:02 AM

View PostSeaGtGruff, on Thu Sep 22, 2011 10:56 PM, said:

. I don't remember which game(s) did this, but at least one game did use BRK interrupts to play different sounds.
I found that Parker is using this trick in several games (to save some ROM space). One of them is Lord Of The Rings.

http://www.biglist.c...2/msg00093.html




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users