Jump to content
IGNORED

Inverting Bytes


Jedd

Recommended Posts

I just thought, since in most other languages you set up an array, where as in Asm you just put a bunch of bytes one after another. It seems like less of an array than other languages, and that's why I wasnt sure if it was ok. Thanks for clearing that up.

 

-J

Link to comment
Share on other sites

Ok I'm still really confused why my program doesn't work. It should scroll through the array that I made, with the right side symetrical (but not mirrored) and inverted. From what I can see, the first vertical line of playfeild (which is 10 scanlines high) is working, while the rest are all screwed up. Can anyone tell me what I did wrong? Thanks a bunch!

 

-J

 

It won't let me upload a file that's .asm, so here's the code:

 




processor 6502

include "vcs.h"

include "macro.h"



Scroll  = $80

BlCount  = $81



SEG

ORG $F000



Reset



ldx #0

lda #0



Clear

sta 0,x

inx

bne Clear



lda #$84

sta COLUPF



lda #$04

sta COLUBK



lda #%00000000

sta CTRLPF



lda #%11111111

sta PF0



Frame



lda #0

sta VBLANK



lda #2

sta VSYNC



sta WSYNC

sta WSYNC

sta WSYNC



lda #0

sta VSYNC



ldx #37

TopBlank

sta WSYNC

dex

bne TopBlank



ldx #0



Pic



lda #0

sta BlCount



Block



sta WSYNC



ldy Scroll,x



lda LData1,y

sta PF1



lda LData2,y

sta PF2



inc BlCount

ldy BlCount



Sleep 12



lda LData1,y

EOR #$FF

sta PF1



lda LData2,y

EOR #$FF

sta PF2



cpy #10

bne Block



inx

cpx #20

bne Pic



ldy Scroll

cpy #180

bne NoReset

lda #0

sta Scroll



NoReset



inc Scroll



lda #%01000010

sta VBLANK



ldx #30

Overscan

sta WSYNC

dex

bne Overscan



jmp Frame



LData1

       .byte #%00000000

       .byte #%00000000

       .byte #%00000001

       .byte #%00000010

       .byte #%00000100

       .byte #%00001000

       .byte #%00001000

       .byte #%00010000

       .byte #%00010000

       .byte #%00010000

       .byte #%00100000

       .byte #%00100000

       .byte #%00100000

       .byte #%00100000

       .byte #%00010000

       .byte #%00010000

       .byte #%00001000

       .byte #%00000100

       .byte #%00000011

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000001

       .byte #%00000001

       .byte #%00000010

       .byte #%00000010

       .byte #%00000100

       .byte #%00000100

       .byte #%00001000

       .byte #%00001000

       .byte #%00001000

       .byte #%00001000

       .byte #%00000100

       .byte #%00000100

       .byte #%00000010

       .byte #%00000001

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000001

       .byte #%00000010

       .byte #%00000100

       .byte #%00001000

       .byte #%00010000

       .byte #%00010000

       .byte #%00100000

       .byte #%00100000

       .byte #%01000000

       .byte #%01000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%01000000

       .byte #%01000000

       .byte #%01000000

       .byte #%00100000

       .byte #%00100000

       .byte #%00010000

       .byte #%00001000

       .byte #%00000100

       .byte #%00000100

       .byte #%00000010

       .byte #%00000010

       .byte #%00000001

       .byte #%00000001

       .byte #%00000001

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000001

       .byte #%00000001

       .byte #%00000001

       .byte #%00000010

       .byte #%00000010

       .byte #%00000010

       .byte #%00000100

       .byte #%00000100

       .byte #%00001000

       .byte #%00001000

       .byte #%00010000

       .byte #%00010000

       .byte #%00100000

       .byte #%00100000

       .byte #%01000000

       .byte #%01000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%01000000

       .byte #%01000000

       .byte #%01000000

       .byte #%01000000

       .byte #%01000100

       .byte #%10001100

       .byte #%10011100

       .byte #%10011100

       .byte #%10111100

       .byte #%00111000

       .byte #%01111000

       .byte #%01111000

       .byte #%01111000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11100000

       .byte #%11100000

       .byte #%11100000

       .byte #%11100000

       .byte #%11000000

       .byte #%11000000

       .byte #%11000000

       .byte #%11000000

       .byte #%01000000

       .byte #%01000000

       .byte #%01000000

       .byte #%00100000

       .byte #%00100000

       .byte #%00100000

       .byte #%11000000

       .byte #%11000000

       .byte #%11000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%10000000

       .byte #%10000000

       .byte #%10000000

       .byte #%11000000

       .byte #%11000000

       .byte #%11000000

       .byte #%11100000

       .byte #%11100000

       .byte #%11100000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000

       .byte #%11110000



LData2

       .byte #%00000001

       .byte #%00000001

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000011

       .byte #%00000100

       .byte #%00001000

       .byte #%00010000

       .byte #%00010000

       .byte #%00100000

       .byte #%00100000

       .byte #%01000000

       .byte #%01000000

       .byte #%01000000

       .byte #%01000000

       .byte #%00100000

       .byte #%00100000

       .byte #%00010000

       .byte #%00010000

       .byte #%00001000

       .byte #%00000100

       .byte #%00000010

       .byte #%00000001

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000001

       .byte #%00000001

       .byte #%00000010

       .byte #%00000010

       .byte #%00000010

       .byte #%00000001

       .byte #%00000001

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000001

       .byte #%00000001

       .byte #%00000001

       .byte #%00000001

       .byte #%00000001

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%10000000

       .byte #%11000000

       .byte #%11000000

       .byte #%11000000

       .byte #%11000000

       .byte #%11000000

       .byte #%10000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000

       .byte #%00000000





ORG $FFFA



.word Reset

.word Reset

.word Reset



END

 

Remember I'm still a newbie, so don't make fun of my crappy code! :D

Link to comment
Share on other sites

As all Real Programmers know, the only useful data structure is the Array. Strings, Lists, Structures, Sets-- these are all special cases of arrays and can be treated that way just as easily without messing up your programming language with all sorts of complications.

 

No, there are no data structures; only data stored in memory. How the program choses to interpret that data is up to the programmer.

 

Of course, you could get even more literal and talk about bits or electrical signals, but some degree of abstraction and equivalence is necessary to stay sane.

Link to comment
Share on other sites

:( That didn't work either. What that line is doing is taking the location of the original starting byte of the playfeild data for that screen, and adds it to the scanline (actually, the vertical pixel) for that screen and loads it into x. Then it looks up the byte at that location for PF1 and PF2. Without the ,x , it would look up the same byte of PF information for each scanline of the screen, making the screen always have vertical lines.

 

I was thinking maybe I have too many 6502 cycles going on, so maybe the lines are falling into the next line, and the data is overlapping the other scanlines. I counted the # of cycles and it looked like it made it, does anyone else see an error there?

 

-J

Link to comment
Share on other sites

Hi there!

 

What that line is doing is taking the location of the original starting byte of the playfeild data for that screen, and adds it to the scanline (actually, the vertical pixel) for that screen and loads it into x.

 

No. What that line is doing is reading different RAM values into Y, depending on X. First it reads from $80, then from $81 and so on, until with X = $20 you're reading from $A0. Then you're resetting X to zero thus starting all over reading from $80 again.

 

Greetings,

Manuel

Link to comment
Share on other sites

Also you should load your scroll offset outside of the display loop.

But like always I'm brining up a non-critical issue ;)

 

So, before sta WSYNC? Because I had it that way before, then I realized I might as well put it in since I'm having the 6502 sleep for a while anyway.

 

I still can't get it to work! I think I'm going to just start over and completely re-write the code.

 

-J

Link to comment
Share on other sites

  • 3 weeks later...

I got frustrated and left Atari programming for a few weeks, but today I was bored so I re-coded my scrolling program. Unfortunately it still does not work. Here are the guts of my program:

 

;192 lines of picture



ldx #0

stx Scanline



inc Scroll



sta WSYNC



Pic



inc Scanline



ldx Scanline

ldy Scroll,x



lda PFData0,y

sta PF0

lda PFData1,y

sta PF1

lda PFData2,y

sta PF2



ldx #0

stx Skip8



Block

sta WSYNC

inc Skip8

ldx Skip8

cpx #10

bne Block



ldx Scanline

cpx #19

bne Pic


;End lines of picture

 

Or you can download the whole thing here.

 

From what I can see it should work. Scroll and Scanline are both increasing the way they should be. Scroll increases once every frame, Scanline increases once every 10 scanlines. But for some reason when they are added together, you get 0. Can anyone pleeeeeease tell me why it doesn't work?

 

-J

Link to comment
Share on other sites

How's it hangin' Jedd?

 

CLC

Clears the carry flag. By "clear" I mean "make it zero".

 

ADC

Adds the operand to the acc, then adds in the carry flag.

 

So, having a CLC ADC combo does a simple ADD, assuming the 6502 has an ADD instruction, which it doesn't (MOS-Tek were a bunch of cheap SOB's :).

 

You really ought to know basic stuff like this...

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