Jump to content
IGNORED

Help Character Position


Recommended Posts

When I run this code on 8bitworkshop my sip is toward the left side of the screen (which is what i want), but when i run the code on z26 emulator it's still facing toward the right of the screen.

 

    processor 6502
    include "vcs.h"
    include "macro.h"
;variables
    seg.u Variables
    org $80

 

YPosFromBot = $80;
VisiblePlayerLine = $81;
PlayerBuffer = $82 ;setup an extra variable    
    
    seg Code
    org $F000

;generic start up stuff...
Start:
    CLEAN_START
    
ClearMem 
    sta 20,x        
    dex        
    bne ClearMem    
    lda #$00        
    sta COLUBK    ;start with black background
    lda #$08
    sta COLUP0
    
;Setting some variables...
    lda #80
    sta YPosFromBot    ;Initial Y Position
    lda #$20    
    sta NUSIZ0    ;Quad Width

;VSYNC time
MainLoop:
    lda #2
    sta VSYNC    
    sta WSYNC    
    sta WSYNC     
    sta WSYNC    
    lda #43    
    sta TIM64T    
    lda #0
    sta VSYNC 

Movement:
    lda #%00010000    ;Down?
    bit SWCHA 
    bne SkipMoveDown
    inc YPosFromBot
SkipMoveDown

    lda #%00100000    ;Up?
    bit SWCHA 
    bne SkipMoveUp
    dec YPosFromBot
SkipMoveUp

WaitForVblankEnd:
    lda INTIM    
    bne WaitForVblankEnd    
    ldy #191     
    sta WSYNC
    sta VBLANK 
    
ScanLoop:
    sta WSYNC

    lda PlayerBuffer ;buffer was set during last scanline
    sta GRP0         ;put it as graphics now        
    
CheckActivatePlayer
    CPY YPosFromBot
    bne SkipActivatePlayer
    lda #8
    sta VisiblePlayerLine 
SkipActivatePlayer


    lda #0        
    sta PlayerBuffer   ;set buffer, not GRP0

    ldx VisiblePlayerLine    ;check the visible player line...
    BEQ FinishPlayer    ;skip the drawing if its zero...
    
IsPlayerOn    
    lda Ship-1,x    ;otherwise, load the correct line from Ship
    sta PlayerBuffer    ;put that line as player graphic for the next line
    dec VisiblePlayerLine     ;and decrement the line count
FinishPlayer

    dey        
    bne ScanLoop    

    lda #2        
    sta WSYNC      
    sta VBLANK     
    ldx #30
    
OverScanWait:
    sta WSYNC
    dex
    bne OverScanWait
    jmp MainLoop
    
Ship:
    .byte #%00000000
    .byte #%00100000
    .byte #%01111000
    .byte #%11111100
    .byte #%01111111
    .byte #%11111100
    .byte #%01111000
    .byte #%00100000      
    
    org $FFFC
    .word Start
    .word Start

Link to comment
Share on other sites

If you use the code tag (left of the eye eye con) then you you get easier-to-read code. Will look at it soon...

 

    processor 6502
    include "vcs.h"
    include "macro.h"
;variables
    seg.u Variables
    org $80



YPosFromBot = $80;
VisiblePlayerLine = $81;
PlayerBuffer = $82 ;setup an extra variable    
    
    seg Code
    org $F000

;generic start up stuff...
Start:
    CLEAN_START
    
ClearMem 
    sta 20,x        
    dex        
    bne ClearMem    
    lda #$00        
    sta COLUBK    ;start with black background
    lda #$08
    sta COLUP0
    
;Setting some variables...
    lda #80
    sta YPosFromBot    ;Initial Y Position
    lda #$20    
    sta NUSIZ0    ;Quad Width

;VSYNC time
MainLoop:
    lda #2
    sta VSYNC    
    sta WSYNC    
    sta WSYNC     
    sta WSYNC    
    lda #43    
    sta TIM64T    
    lda #0
    sta VSYNC 

Movement:
    lda #%00010000    ;Down?
    bit SWCHA 
    bne SkipMoveDown
    inc YPosFromBot
SkipMoveDown

    lda #%00100000    ;Up?
    bit SWCHA 
    bne SkipMoveUp
    dec YPosFromBot
SkipMoveUp

WaitForVblankEnd:
    lda INTIM    
    bne WaitForVblankEnd    
    ldy #191     
    sta WSYNC
    sta VBLANK 
    
ScanLoop:
    sta WSYNC

    lda PlayerBuffer ;buffer was set during last scanline
    sta GRP0         ;put it as graphics now        
    
CheckActivatePlayer
    CPY YPosFromBot
    bne SkipActivatePlayer
    lda #8
    sta VisiblePlayerLine 
SkipActivatePlayer


    lda #0        
    sta PlayerBuffer   ;set buffer, not GRP0

    ldx VisiblePlayerLine    ;check the visible player line...
    BEQ FinishPlayer    ;skip the drawing if its zero...
    
IsPlayerOn    
    lda Ship-1,x    ;otherwise, load the correct line from Ship
    sta PlayerBuffer    ;put that line as player graphic for the next line
    dec VisiblePlayerLine     ;and decrement the line count
FinishPlayer

    dey        
    bne ScanLoop    

    lda #2        
    sta WSYNC      
    sta VBLANK     
    ldx #30
    
OverScanWait:
    sta WSYNC
    dex
    bne OverScanWait
    jmp MainLoop
    
Ship:
    .byte #%00000000
    .byte #%00100000
    .byte #%01111000
    .byte #%11111100
    .byte #%01111111
    .byte #%11111100
    .byte #%01111000
    .byte #%00100000      
    
    org $FFFC
    .word Start
    .word Start

 

Link to comment
Share on other sites

I would be trusting Stella to give accurate emulation results over z26. Often emulators have to deal with tricky timing and don't always get it right. The ultimate test is hardware, but Stella (and Gopher2600) are pretty close! I think z26's engine is a bit older and perhaps not quite as accurate.

 

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