Jump to content
IGNORED

Can you spot the bug?


Fort Apocalypse

Recommended Posts

:( Compiles. Won't run. Have tried commenting out various new sections of code, but haven't found the issue.

It didn't compile all the way-- notice that the .BIN is only 2.43K, not 4K. You didn't post the source, but looking at the .BIN in DIS6502, and comparing it to an assembly listing from the 0.8 version, it looks like it stopped assembling at the point where you're doing something with the paddle. Here's the last bit of code from the (aborted) assembly of 0.9:

 

LF9AF	 LDA L0091	; A5 91
	  SEC		  ; 38
	  SBC #$26	 ; E9 26
	  LSR		  ; 4A
	  LSR		  ; 4A
	  LSR		  ; 4A
	  LSR		  ; 4A
	  STA L00ED	; 85 ED <-- This is the last line that assembled, so the error must be right after this.

And here's a similar-but-different section of the assembly listing from 0.8:

 

   3161  f9eb				   .paddletotempdir16max
  3162  f9eb						; paddletotempdir16max
  3163  f9eb
  3164  f9eb				   .L0219	;  tempdir16max  =   ( paddle	/  5 )	 +  1
  3165  f9eb
  3166  f9eb						; complex statement detected
  3167  f9eb			   a5 91			  LDA	paddle
  3168  f9ed			   a0 05			  LDY	#5
  3169  f9ef			   20 0c f4 		  jsr	div8
  3170  f9f2			   18			  CLC
  3171  f9f3			   69 01			  ADC	#1
  3172  f9f5			   85 ef			  STA	tempdir16max
  3173  f9f7				   .L0220	;  if tempdir16max  >	16 then tempdir16max  =  1
  3174  f9f7
  3175  f9f7			   a9 10			  LDA	#16
  3176  f9f9			   c5 ef			  CMP	tempdir16max
  3177  f9fb			   b0 04			  BCS	.skipL0220
  3178  f9fd				   .condpart105
  3179  f9fd			   a9 01			  LDA	#1
  3180  f9ff			   85 ef			  STA	tempdir16max
  3181  fa01				   .skipL0220
  3182  fa01				   .L0221	;  if tempdir16max  <	1 then tempdir16max  =	16
  3183  fa01
  3184  fa01			   a5 ef			  LDA	tempdir16max
  3185  fa03			   c9 01			  CMP	#1
  3186  fa05			   b0 04			  BCS	.skipL0221
  3187  fa07				   .condpart106
  3188  fa07			   a9 10			  LDA	#16
  3189  fa09			   85 ef			  STA	tempdir16max
  3190  fa0b				   .skipL0221
  3191  fa0b				   .L0222	;  return
  3192  fa0b
  3193  fa0b			   60			  RTS

Here's the batari Basic code for that part, from the source of 0.8:

 

paddletotempdir16max
tempdir16max = (paddle / 5) + 1
if tempdir16max > 16 then tempdir16max = 1
if tempdir16max < 1 then tempdir16max = 16
return

It seems like you may have tried to do something to that section of code-- perhaps to make it more compact?-- and maybe it got too complex for bB to handle. But that's just a guess, and it's hard to tell without the source for 0.9.

 

Michael

Link to comment
Share on other sites

P.S. Thanks for the info on how you figured it out. I need to start looking at the partially compiled code to help myself... I just see stuff like:

 

---------- Capture Output ----------
2600 Basic compilation complete.
DASM V2.20.07, Macro Assembler (C)1988-2003
  bytes of ROM space left
  83 bytes of ROM space left
Possible duplicate label: L0278 fb78				  
> Terminated with exit code 0.

 

then try commenting code or putting stuff like:

if asfd = fdas then asfd = 4 : asff = 5

 

into the code and recompiling (because putting bad code in sometimes help expose other bad code). And if that doesn't work I usually have started just commenting out parts of the code, until I find the offending piece. Your way is much better!

 

BTW- sorry I haven't done much stuff in bB side of wiki. I kind of froze up when I started into it and have been wondering since how to get batari/Random Terrain's great single html page (which is easy to search, etc) into a lot of different pages easily and so it looks good. The only way I can think to start it is by copying the whole html into the wiki page and converting to wiki (the body without the right nav/link bar) but then I freeze up thinking about how to start copying those functions and creating their own pages, and I somehow think I'm going to run into problems converting it into just a straight list of functions... I just need to do it though.

Edited by Fort Apocalypse
Link to comment
Share on other sites

That's weird, it appears to compile all the way-- the assembly listing goes all the way to $FFFF and the startup vectors-- but the .BIN isn't 4K. I'll check the .BIN disassembly against the assembly listing tonight to see what I can figure out.

 

Michael

Okay, I see what happened. The assembly listing does go all the way to the end, but it didn't resolve all of the addresses. Here's the last section of code in the 0.9 .BIN file, as displayed by DIS6502:

 

LF9A7	 LDA L0091	; A5 91
	  SEC		  ; 38
	  SBC #$26	 ; E9 26
	  LSR		  ; 4A
	  LSR		  ; 4A
	  LSR		  ; 4A
	  LSR		  ; 4A
	  STA L00ED	; 85 ED

And here's the equivalent section of the assembly listing, along with the part that immediately follows it:

 

   3116  f9a7		  .incrdir
  3117  f9a7				   ; incrdir
  3118  f9a7
  3119  f9a7		  .L0214   ; tempx = (paddle - 38) / 16
  3120  f9a7
  3121  f9a7				   ; complex statement detected
  3122  f9a7   a5 91	  LDA   paddle
  3123  f9a9   38		 SEC
  3124  f9aa   e9 26	  SBC   #38
  3125  f9ac   4a		 lsr
  3126  f9ad   4a		 lsr
  3127  f9ae   4a		 lsr
  3128  f9af   4a		 lsr
  3129  f9b0   85 ed	  STA   tempx
  3130  f9b2		  .L0215   ; tempdirmax = tempdirmax + tempx
  3131  f9b2
  3132  f9b2   ad 00 00   LDA   tempdirmax
  3133  f9b5   18		 CLC
  3134  f9b6   65 ed	  ADC   tempx
  3135  f9b8   8d 00 00   STA   tempdirmax
  3136  f9bb		  .L0216   ; return
  3137  f9bb
  3138  f9bb   60		 RTS

This is the specific statement that's causing the assembly to fail:

 

   tempdirmax = tempdirmax + tempx

And this shows why it's failing:

 

   3132  f9b2   ad 00 00   LDA   tempdirmax

That line should be loading the accumulator with the contents of tempdirmax, but the address of tempdirmax is $0000-- i.e., it hasn't been defined. If you search your bB code for "tempdirmax," you'll see it's used in the "incrdir" and "decrdir" subroutines, but it's never dimmed anywhere. However, you do make extensive use of a variable named "tempdir16max," so I'm guessing that you just forgot to type the "16" in that variable name when you wrote those two subroutines. :ponder:

 

Michael

Link to comment
Share on other sites

Doh! That was it. Thanks, Michael!

You're welcome.

 

By the way, I highly recommend DIS6502. It was written for working with files and programs for the 8-bit Atari computers, but you can easily set it up to work with ROM images for the 2600. I should try to post some how-to instructions for using it, because it's a great alternative to Distella.

 

Assembly listings are also extremely helpful. I definitely recommend modifying your DASM command line to generate a listing when you assemble your games.

 

Michael

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