BadBoy House Posted February 2, 2006 Share Posted February 2, 2006 i've been looking at a number of commented dissassemblies - one of the shorter ones is the code for Outlaw. What's confusing me is the commands that are used in each line: ; RAM variables: PF0Array = $80 ; PF0 array, 18 Bytes ScoreshapeLow01 = $92 ; Shape of player 1 lower score digit ScoreshapeLow02 = $93 ; Shape of player 2 lower score digit ScoreshapeHi01 = $94 ; Shape of player 1 higher score digit ScoreshapeHi02 = $95 ; Shape of player 2 higher score digit ; Draws the playfield and bullet 1 & increments the kernels linecounter STA PF2 ; Draw PF2 LDA vertPosition01 ; A-> vertical pos player 1 SBC lineCounter ; Current pos above player1? BPL SkipDraw2 ; Y: SkipDraw1 LDY shapeOffset01 ; Y-> shapeOffset01 LDA LF6FE,Y ; A-> player 1 shape TAY ; Y-> player 1 shape LDA PF0Array,X ; A->PF0 data (obstacle) STA.w $000D ; Draw PF0 (4 cycles!) LDA lineCounter ; A->lineCounter CMP bulletVerPos01 ; Check for bullet 1 PHP ; En/Disable bullet 1 LDA PF1Array,X ; A->PF1 data (obstacle) STA PF1 ; Draw PF1 LDA PF2Array02,X ; A->PF2 data (frame) STA PF2 ; Draw PF2 PLA ; Restore... Whilst there are comments which say what each line does, I'm interested to learn from a master list what each command does. For instance, these three lines: PF0Array = $80 ; PF0 array, 18 Bytes ScoreshapeLow01 = $92 ; Shape of player 1 lower score digit PHP ; En/Disable bullet 1 where could i find out that the PHP command enables/disables bullets? and what the PF0Array command actually does. thanks in advance Quote Link to comment Share on other sites More sharing options...
Cybergoth Posted February 2, 2006 Share Posted February 2, 2006 You're not knowing anything about programming at all, or? Quote Link to comment Share on other sites More sharing options...
Tom Posted February 2, 2006 Share Posted February 2, 2006 I told you already not to start staring at disassemblies right away. You won't get anywhere with that little bit of knowledge you have... Quote Link to comment Share on other sites More sharing options...
+Allan Posted February 2, 2006 Share Posted February 2, 2006 (edited) Read one or more of these books first to atleast get familiar with 6502 instruction set(commands). http://www.atariarchives.org/alp/ http://www.atariarchives.org/mlb/ http://www.atariarchives.org/roots/ Allan Edited February 2, 2006 by Allan Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted February 2, 2006 Share Posted February 2, 2006 (edited) You don't need to read a book to understand 6502 assembly and the 2600. Well, you might, but you should start by reading these; if you can't understand after reading these then read some of those books. To understand 6502 assembly language: Assembly In One Step Quick reference for assembly: 6502 Opcodes Understanding how the 2600 works: Stella Programmer's Guide Edited February 2, 2006 by vdub_bobby Quote Link to comment Share on other sites More sharing options...
+Allan Posted February 2, 2006 Share Posted February 2, 2006 You don't need to read a book to understand 6502 assembly and the 2600. Well, you might, but you should start by reading these; if you can't understand after reading these then read some of those books. To understand 6502 assembly language: Assembly In One Step Quick reference for assembly: 6502 Opcodes Understanding how the 2600 works: Stella Programmer's Guide 1011525[/snapback] By looking at his post I'm going to guess he has very little programming experience and should probably start with a book written for beginners, not a quick reference sheet written for seasoned programmers. There's also the well-wriiten 2600 programmers guide written Andrew Davies (right?) which is better suited for beginners. Allan Quote Link to comment Share on other sites More sharing options...
vdub_bobby Posted February 2, 2006 Share Posted February 2, 2006 I dunno. You could be a somewhat experienced BASIC programmer and have the same reaction to assembly as he did. And the Assembly In One Step document isn't for seasoned programmers; not in my opinion anyway. I consulted it all the time in my first few months of 2600/assembly coding; I haven't looked at it at all for at least 7-8 months now that I am more experienced. The opcode list and the Stella Guide, on the other hand, I have consulted frequently throughout my 2600 coding. I consulted them at the very beginning and I still consult them. The opcode list mostly for timings of uncommon opcodes (or to confirm that a INC ZP,Y opcode doesn't exist, dammit all), the Stella Guide for quick reminders of which bits in the collision registers I want to check and other little details. Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted February 3, 2006 Share Posted February 3, 2006 Whilst there are comments which say what each line does, I'm interested to learn from a master list what each command does. For instance, these three lines: PF0Array = $80 ; PF0 array, 18 Bytes ScoreshapeLow01 = $92 ; Shape of player 1 lower score digit PHP ; En/Disable bullet 1 where could i find out that the PHP command enables/disables bullets? and what the PF0Array command actually does. 1011241[/snapback] The "PF0Array = $80" line isn't a "command" per se, it's an equate. It has two basic purposes: it tells the assembler that wherever "PF0Array" is seen in the program code, it is to be replaced (during the assembly process) with "$80"; and it helps make it easier for people to read or write the program code, since the programmer can just refer to "PF0Array" instead of having to write "$80" (which isn't self-explanatory the way that "PF0Array" is). Same with "ScoreshapeLow01 = $92". "PHP", on the other hand, is a 6502 assembly command which means "PusH the Processor status onto the stack." By itself, that doesn't mean "enable or disable bullet 1," although that is apparently what it's being used to do in this game. Michael Rideout Quote Link to comment Share on other sites More sharing options...
BadBoy House Posted February 3, 2006 Author Share Posted February 3, 2006 cheers for all your replies guys. i've got myself a copy of the machine code for beginners book as well as the stella programmers guide. i'll work through those. Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted April 1, 2006 Share Posted April 1, 2006 Whilst there are comments which say what each line does, I'm interested to learn from a master list what each command does. For instance, these three lines: PF0Array = $80 ; PF0 array, 18 Bytes ScoreshapeLow01 = $92 ; Shape of player 1 lower score digit PHP ; En/Disable bullet 1 where could i find out that the PHP command enables/disables bullets? and what the PF0Array command actually does. 1011241[/snapback] The "PF0Array = $80" line isn't a "command" per se, it's an equate. It has two basic purposes: it tells the assembler that wherever "PF0Array" is seen in the program code, it is to be replaced (during the assembly process) with "$80"; and it helps make it easier for people to read or write the program code, since the programmer can just refer to "PF0Array" instead of having to write "$80" (which isn't self-explanatory the way that "PF0Array" is). Same with "ScoreshapeLow01 = $92". "PHP", on the other hand, is a 6502 assembly command which means "PusH the Processor status onto the stack." By itself, that doesn't mean "enable or disable bullet 1," although that is apparently what it's being used to do in this game. Michael Rideout Yup...the enable/disable code you are looking for is probably just below the code snippet you posted. The result of the CMP is pushed to the stack with PHP, and then pulled back as a value using PLA. Just below that instruction, I'll bet there's a STA ENAxx instruction...where bit 1 of that value (when set) would enable the object. Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted April 2, 2006 Share Posted April 2, 2006 The stack is probably pointed at the ENAxx locations - that's what I'm using in Medieval Mayhem to control the ball and missiles. ... this is at the end of a scanline ldx #ENABL txs ; point stack to the ball's enabler register dey ; decrement the line counter cpy BLy ; compare the line counter with Ball's Y position sta WSYNC ; wait until end of current scan line php ; 3 set BALL on/off - pushes Z flag into ball's enabler then positions stack to M1's enabler cpy M1y ; 3 6 compare line counter with Missile 1's Y position php ; 3 9 set Missile 1 on/off - pushes Z flag into M1's enabler then positions stack to M0's enabler cpy M0y ; 3 12 compare line counter with Missile 0's Y position php ; 3 15 set Missile 0 on/off The compare sets the Z flag when the Y positions match. The Z flag is convienently in bit 1 when the processor's status is pushed on the stack. With the prep work before the sta WSYNC only 15 cycles are needed in the time critical horizontal blank to turn on/off all 3 fireballs. After the last PHP the stack pointer is now pointing at GRP1. As such, this could be modified to draw the sprites as well, ala: ... this is at the end of a scanline ldx #ENABL txs ; point stack to the ball's enabler register dey ; decrement the line counter lda Player0,y; load shape for Player 0 tax lda Player1,y; load shape for Player 1 cpy BLy ; compare the line counter with Ball's Y position sta WSYNC ; wait until end of current scan line php ; 3 set BALL on/off - pushes Z flag into ball's enabler then positions stack to M1's enabler cpy M1y ; 3 6 compare line counter with Missile 1's Y position php ; 3 9 set Missile 1 on/off - pushes Z flag into M1's enabler then positions stack to M0's enabler cpy M0y ; 3 12 compare line counter with Missile 0's Y position php ; 3 15 set Missile 0 on/off - pushes Z flag into M0's enabler then position stack to GRP1 pha ; 3 18 push graphic shape into GRP1 then position stack to GRP0 txa ; 2 20 retrieve graphic shape for Playe r0 pha ; 3 23 push graphic shape into GRP0 The only issue here is cycle 23 is a pixel or two after the screen has begun to draw so there'd be shearing if player 0 was on the left edge of the screen. Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted April 2, 2006 Share Posted April 2, 2006 The stack is probably pointed at the ENAxx locations - that's what I'm using in Medieval Mayhem to control the ball and missiles.[...] The compare sets the Z flag when the Y positions match. The Z flag is convienently in bit 1 when the processor's status is pushed on the stack. With the prep work before the sta WSYNC only 15 cycles are needed in the time critical horizontal blank to turn on/off all 3 fireballs. After the last PHP the stack pointer is now pointing at GRP1. As such, this could be modified to draw the sprites as well, ala: [...] The only issue here is cycle 23 is a pixel or two after the screen has begun to draw so there'd be shearing if player 0 was on the left edge of the screen. Very cool, thanks for sharing this! Michael Rideout Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted April 2, 2006 Share Posted April 2, 2006 Oops...I forgot about that (Trickshot does the same thing for the "cue"). Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted April 14, 2006 Share Posted April 14, 2006 (edited) I'm using a variation of this to draw the dragon in Medieval Mayhem and realized there's no need to TAX then PHA, just use STX. This saves 2 cycles and lets you draw all 5 objects before the start of the scanline! ... this is at the end of a scanline ldx #ENABL txs ; point stack to the ball's enabler register dey ; decrement the line counter lda Player0,y; load shape for Player 0 tax lda Player1,y; load shape for Player 1 cpy BLy; compare the line counter with Ball's Y position sta WSYNC ; wait until end of current scan line php ; 3 set BALL on/off - pushes Z flag into ball's enabler then positions stack to M1's enabler cpy M1y; 3 6 compare line counter with Missile 1's Y position php ; 3 9 set Missile 1 on/off - pushes Z flag into M1's enabler then positions stack to M0's enabler cpy M0y; 3 12 compare line counter with Missile 0's Y position php ; 3 15 set Missile 0 on/off - pushes Z flag into M0's enabler then position stack to GRP1 pha ; 3 18 push graphic shape into GRP1 then position stack to GRP0 stx GRP0 ; 3 21 It would also make sense to change the PHA to STA GRP1 so that it's more obvious what the code is doing. Of course, that would use 1 additional byte of ROM. Edited April 14, 2006 by SpiceWare 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.