Display kernel for 5 Card stud Poker

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Al_Nafuur

I am currently trying to build a display kernel for an online 5 card stud game to play on the 2600 via PlusROM function with FuijNet devices:


But I can't find the cycles to change the color and the player graphics for a player (Three copies - close)

    processor 6502
    include "vcs.h"
    include "macro.h"

    org  $f000

colors    equ $80

; Bitmap pattern for cards (will be S-RAM loaded via PlusROM)
; First byte not used (todo: optimize)
CARD_P1_0
    .byte $00,$EE,$AA,$AA,$AA,$EE
CARD_P1_1
    .byte $00,$22,$22,$22,$22,$22
CARD_P1_2
    .byte $00,$EE,$88,$EE,$22,$EE
CARD_P1_3
    .byte $00,$EE,$22,$66,$22,$EE
CARD_P1_4
    .byte $00,$AA,$AA,$EE,$22,$22
CARD_P1_5
    .byte $00,$EE,$88,$EE,$22,$EE
CARD_P1_6    ; max 5 cards, so status info for this player
    .byte $00,$EE,$88,$EE,$AA,$EE
CARD_P2_0
    .byte $00,$EE,$22,$22,$22,$22
CARD_P2_1
    .byte $00,$EE,$AA,$EE,$AA,$EE
CARD_P2_2
    .byte $00,$EE,$AA,$EE,$22,$EE
; more data (120 bytes total) for all 5 players

; Initialize and set initial offsets of objects.
start    CLEAN_START
    lda #20
    ldx #0
    stx colors+1
    stx colors+3
    stx colors+6
    jsr SetHorizPos    ; set player 0 horiz. pos
    inx
    lda #68
    jsr SetHorizPos    ; set player 1 horiz. pos
    inx
    lda #3
    sta NUSIZ0    ; make missile 0 2x-wide
    inx
    lda #3
    sta NUSIZ1    ; make missile 1 4x-wide
    inx
    lda #$30
    sta CTRLPF    ; set ball 8x-wide
    sta WSYNC
    sta HMOVE
    lda #$40
    sta colors
    sta colors+2
    sta colors+4
    sta colors+5
    ldx #$C2
    stx COLUBK    ; set the background color
       
; We've technically generated an invalid frame because
; these operations have generated superfluous WSYNCs.
; But it's just at the beginning of our program, so whatever.

; Next frame loop
nextframe
    VERTICAL_SYNC
   
; 36 lines of VBLANK
    ldx #36
lvblank
    sta WSYNC
    dex
    bne lvblank

; Draw 192 scanlines

    lda #0        ; A changes every scanline
    ldx #20
header
    sta WSYNC    ; wait for next scanline
    dex
    bne header

    stx GRP1
    stx GRP0

    ldx #5        ; X is sprite data index
    SLEEP 24

lvscan
    lda colors
    sta COLUP0
    lda colors+3
    sta COLUP1
    lda CARD_P1_0,x
    sta GRP0    ; set sprite 0 pixels

    sta WSYNC    ; wait for next scanline
    lda CARD_P1_3,x
    sta GRP1    ; set sprite 1 pixels
    ldy CARD_P1_1,x
    lda colors+1
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    sty GRP0
    sta COLUP0
    lda colors+2
    sta COLUP0
    SLEEP 4        ; change copies/color of GRP1 here.

    dex
    bne lvscan    ; repeat next scanline until finished
   
; Repeat code above for all 5 poker players

; Clear all colors to black before overscan
    stx COLUP0
    stx COLUP1
    stx COLUPF
    stx GRP1
    stx GRP0

    ldx #167
footer
    sta WSYNC    ; wait for next scanline
    dex
    bne footer

; 30 lines of overscan
    ldx #25
lvover
    sta WSYNC
    dex
    bne lvover
   
    jmp nextframe

; SetHorizPos - Sets the horizontal position of an object.
; The X register contains the index of the desired object:
;  X=0: player 0
;  X=1: player 1
;  X=2: missile 0
;  X=3: missile 1
;  X=4: ball
; This routine does a WSYNC and HMOVE before executing,
; so whatever you do here will not take effect until you
; call the routine again or do your own WSYNC and HMOVE.
SetHorizPos
    sta WSYNC    ; start a new line
    sta HMOVE    ; apply the previous fine position(s)
    sta HMCLR    ; reset the old horizontal position(s)
    sec        ; set carry flag
DivideLoop
    sbc #15        ; subtract 15
    bcs DivideLoop    ; branch until negative
    eor #7        ; calculate fine offset
    asl
    asl
    asl
    asl
    sta RESP0,x    ; fix coarse position
    sta HMP0,x    ; set fine offset
    rts        ; return to caller

;;end

; Epilogue
    org $fffc
    .word start
    .word start

Thomas Jentzsch

Do you want to display 3 or 6 sprites per line?

If it is the latter than that would be 12 loads and stores. At 7 cycles each. Do the math. :)

Al_Nafuur

#2
Quote from: Thomas Jentzsch on 11 Feb 2024, 04:36 AMDo you want to display 3 or 6 sprites per line?

If it is the latter than that would be 12 loads and stores. At 7 cycles each. Do the math. :)
only 5 sprites are needed.

The color values are stored in ZP-RAM and loaded not indexed so 6 cycles per color change

Al_Nafuur

�🤔
Maybe not all 5 cards of one player have to be on the same row

Al_Nafuur

Current attempt with two rows per player:
8bit workshop link

processor 6502
include "vcs.h"
include "macro.h"

org  $f000

colors equ $80
card_p equ $A0

; Bitmap pattern for cards (will be S-RAM loaded via PlusROM)
CARD_ACE_CROSS
.byte $00,$AE,$A4,$E4,$AE,$44
CARD_ACE_PIK
.byte $00,$AE,$A4,$EE,$AE,$44
CARD_ACE_HEART
.byte $00,$A0,$A4,$EE,$AE,$4A
CARD_ACE_CARO
.byte $00,$A0,$A4,$EE,$AE,$44

CARD_KING_HEART
.byte $00,$A0,$A4,$CE,$AE,$AA

CARD_1
.byte $00,$22,$22,$22,$22,$22
CARD_2
.byte $00,$EE,$88,$EE,$22,$EE
CARD_3
.byte $00,$EE,$22,$66,$22,$EE
CARD_4
.byte $00,$22,$22,$EE,$AA,$AA
CARD_5
.byte $00,$EE,$22,$EE,$88,$EE
CARD_6
.byte $00,$EE,$AA,$EE,$88,$EE
CARD_7
.byte $00,$22,$22,$22,$22,$EE
CARD_8
.byte $00,$EE,$AA,$EE,$AA,$EE
CARD_9
.byte $00,$EE,$22,$EE,$AA,$EE

; Initialize and set initial offsets of objects.
start CLEAN_START
lda #5
ldx #0
stx colors+1
stx colors+3
stx colors+6
jsr SetHorizPos ; set player 0 horiz. pos
inx
lda #68
jsr SetHorizPos ; set player 1 horiz. pos
inx
lda #6
sta NUSIZ0 ; make missile 0 2x-wide
inx
lda #6
sta NUSIZ1 ; make missile 1 4x-wide
inx
lda #$30
sta CTRLPF ; set ball 8x-wide
sta WSYNC
sta HMOVE
lda #$40
sta colors
sta colors+2
sta colors+4
        lda $0E
sta colors+5
ldx #$C2
stx COLUBK ; set the background color
       
; Load some valid pointers to the player cards
lda #<CARD_ACE_HEART
sta card_p
        lda #>CARD_ACE_HEART
sta card_p+1
        lda #<CARD_ACE_PIK
sta card_p+2
        lda #>CARD_ACE_PIK
sta card_p+3
        lda #<CARD_ACE_CARO
sta card_p+4
        lda #>CARD_ACE_CARO
sta card_p+5
        lda #<CARD_ACE_CROSS
sta card_p+6
        lda #>CARD_ACE_CROSS
sta card_p+7
        lda #<CARD_KING_HEART
sta card_p+8
        lda #>CARD_KING_HEART
sta card_p+9
        lda #<CARD_5
sta card_p+10
        lda #>CARD_5
sta card_p+11
         
; We've technically generated an invalid frame because
; these operations have generated superfluous WSYNCs.
; But it's just at the beginning of our program, so whatever.

; Next frame loop
nextframe
VERTICAL_SYNC

; 36 lines of VBLANK
ldx #36
lvblank
sta WSYNC
dex
bne lvblank

; Draw 192 scanlines

lda #0 ; A changes every scanline
ldx #20
header
sta WSYNC ; wait for next scanline
dex
bne header

stx GRP1
stx GRP0

ldy #5 ; y is sprite data index

lvscan1
sta WSYNC ; wait for next scanline
lda colors
sta COLUP0
lda (card_p),y
sta GRP0 ; set sprite 0 pixels
lda (card_p+2),y
ldx.w colors+1
nop
nop
sta GRP0
stx COLUP0
lda (card_p+4),y
ldx colors+2
sta GRP0
stx COLUP0
dey
bne lvscan1 ; repeat next scanline until finished

sty GRP1
sty GRP0

ldy #5 ; X is sprite data index
sta WSYNC ; wait for next scanline
sta WSYNC ; wait for next scanline

lvscan2
sta WSYNC ; wait for next scanline
lda colors+3
sta COLUP0
lda (card_p+6),y
sta GRP0 ; set sprite 0 pixels
lda (card_p+8),y
ldx.w colors+4
nop
nop
sta GRP0
stx COLUP0
lda (card_p+10),y
ldx colors+5
sta GRP0
stx COLUP0
dey
bne lvscan2 ; repeat next scanline until finished






; Clear all colors to black before overscan
sty COLUP0
sty COLUP1
sty COLUPF
sty GRP1
sty GRP0

ldx #160
footer
sta WSYNC ; wait for next scanline
dex
bne footer

; 30 lines of overscan
ldx #25
lvover
sta WSYNC
dex
bne lvover

jmp nextframe

; SetHorizPos - Sets the horizontal position of an object.
; The X register contains the index of the desired object:
;  X=0: player 0
;  X=1: player 1
;  X=2: missile 0
;  X=3: missile 1
;  X=4: ball
; This routine does a WSYNC and HMOVE before executing,
; so whatever you do here will not take effect until you
; call the routine again or do your own WSYNC and HMOVE.
SetHorizPos
sta WSYNC ; start a new line
sta HMOVE ; apply the previous fine position(s)
sta HMCLR ; reset the old horizontal position(s)
sec ; set carry flag
DivideLoop
sbc #15 ; subtract 15
bcs DivideLoop ; branch until negative
eor #7 ; calculate fine offset
asl
asl
asl
asl
sta RESP0,x ; fix coarse position
sta HMP0,x ; set fine offset
rts ; return to caller

;;end




; Epilogue
org $fffc
.word start
.word start

Al_Nafuur


8bit workshop link

processor 6502
include "vcs.h"
include "macro.h"

LEFT_PLAYERS_XPOS = 18
RIGHT_PLAYERS_XPOS = 66

org  $f000

colors equ $80
cards_pointer equ $A0
current_player equ $C0

; Bitmap pattern for cards (will be S-RAM loaded via PlusROM)
CARD_ACE_CROSS
.byte $00,$A7,$A2,$E2,$A7,$42
CARD_ACE_PIK
.byte $00,$A7,$A2,$E7,$A7,$42
CARD_ACE_HEART
.byte $00,$A0,$A2,$E7,$A7,$45
CARD_ACE_CARO
.byte $00,$A0,$A2,$E7,$A7,$42

CARD_KING_HEART
.byte $00,$A0,$A2,$C7,$A7,$A5
CARD_KING_CROSS
.byte $00,$A7,$A2,$C2,$A7,$A2

CARD_10_HEART
.byte $00,$B0,$B2,$B7,$B7,$B5

CARD_1
.byte $00,$22,$22,$22,$22,$22
CARD_2
.byte $00,$EE,$88,$EE,$22,$EE
CARD_3
.byte $00,$EE,$22,$66,$22,$EE
CARD_4
.byte $00,$22,$22,$EE,$AA,$AA
CARD_5
.byte $00,$EE,$22,$EE,$88,$EE
CARD_6
.byte $00,$EE,$AA,$EE,$88,$EE
CARD_7
.byte $00,$22,$22,$22,$22,$EE
CARD_8
.byte $00,$EE,$AA,$EE,$AA,$EE
CARD_9
.byte $00,$EE,$22,$EE,$AA,$EE

; Initialize and set initial offsets of objects.
start CLEAN_START
lda #LEFT_PLAYERS_XPOS
ldx #0
stx colors+1
stx colors+3
stx colors+6
jsr SetHorizPos ; set player 0 horiz. pos
inx
lda #RIGHT_PLAYERS_XPOS+4
jsr SetHorizPos ; set player 1 horiz. pos
inx
lda #6
sta NUSIZ0 ; make missile 0 2x-wide
inx
lda #0
sta NUSIZ1 ; make missile 1 4x-wide
inx
lda #%1
sta CTRLPF ; set ball 8x-wide
sta WSYNC
sta HMOVE
lda #$40
sta colors
sta colors+2
sta colors+4
        lda $0E
sta colors+5

ldx #$00
stx COLUBK ; set the background color
        ldx #$C2
        stx COLUPF
        lda #$C0
        sta PF0
        lda #$ff
        sta PF1
        sta PF2
;        sta GRP1
;        sta COLUP1
       
; Load some valid pointers to the player cards
lda #<CARD_10_HEART
sta cards_pointer
        lda #>CARD_10_HEART
sta cards_pointer+1
        lda #<CARD_ACE_PIK
sta cards_pointer+2
        lda #>CARD_ACE_PIK
sta cards_pointer+3
        lda #<CARD_ACE_CARO
sta cards_pointer+4
        lda #>CARD_ACE_CARO
sta cards_pointer+5
        lda #<CARD_ACE_CROSS
sta cards_pointer+6
        lda #>CARD_ACE_CROSS
sta cards_pointer+7
        lda #<CARD_KING_HEART
sta cards_pointer+8
        lda #>CARD_KING_HEART
sta cards_pointer+9
        lda #<CARD_5
sta cards_pointer+10
        lda #>CARD_5
sta cards_pointer+11

lda #<CARD_10_HEART
sta cards_pointer+12
        lda #>CARD_10_HEART
sta cards_pointer+13
        lda #<CARD_KING_CROSS
sta cards_pointer+14
        lda #>CARD_KING_CROSS
sta cards_pointer+15
        lda #<CARD_ACE_CARO
sta cards_pointer+16
        lda #>CARD_ACE_CARO
sta cards_pointer+17
        lda #<CARD_ACE_CROSS
sta cards_pointer+18
        lda #>CARD_ACE_CROSS
sta cards_pointer+19
        lda #<CARD_KING_HEART
sta cards_pointer+20
        lda #>CARD_KING_HEART
sta cards_pointer+21
        lda #<CARD_4
sta cards_pointer+22
        lda #>CARD_4
sta cards_pointer+23

; We've technically generated an invalid frame because
; these operations have generated superfluous WSYNCs.
; But it's just at the beginning of our program, so whatever.

; Next frame loop
nextframe
VERTICAL_SYNC

; 36 lines of VBLANK
ldx #36
lvblank
sta WSYNC
dex
bne lvblank

; Draw 192 scanlines

ldx #5
jsr spacer

ldy #11
copy_routine ; 78 cycles !
sta WSYNC ; wait for next scanline
lda cards_pointer,y
        sta current_player,y
        dey
        bpl copy_routine
         

ldy #5 ; y is sprite data index
lvscan1
sta WSYNC ; wait for next scanline
lda colors
sta COLUP0
lda (current_player),y
sta GRP0 ; set sprite 0 pixels
lda (current_player+2),y
ldx.w colors+1
        SLEEP 4
sta GRP0
stx COLUP0
lda (current_player+4),y
ldx colors+2
sta GRP0
stx COLUP0
dey
bne lvscan1 ; repeat next scanline until finished

sty GRP0

ldx #2
jsr spacer

ldy #5 ; y is sprite data index
lvscan2
sta WSYNC ; wait for next scanline
lda colors+3
sta COLUP0
lda (current_player+6),y
sta GRP0 ; set sprite 0 pixels
lda (current_player+8),y
ldx.w colors+4
        SLEEP 4
sta GRP0
stx COLUP0
lda (current_player+10),y
ldx colors+5
sta GRP0
stx COLUP0
dey
bne lvscan2 ; repeat next scanline until finished

sty GRP0
        ldx #0
        lda #RIGHT_PLAYERS_XPOS
        jsr SetHorizPos


ldy #11
copy_routine2 ; 78 cycles !
sta WSYNC ; wait for next scanline
lda cards_pointer+12,y
        sta current_player,y
        dey
        bpl copy_routine2


ldy #5 ; y is sprite data index
lvscan3
sta WSYNC ; wait for next scanline
lda colors
sta COLUP0
lda (current_player),y
sta GRP0 ; set sprite 0 pixels
lda (current_player+2),y
ldx.w colors+1
        SLEEP 20
sta GRP0
stx COLUP0
lda (current_player+4),y
ldx colors+2
sta GRP0
stx COLUP0
dey
bne lvscan3 ; repeat next scanline until finished

sty GRP0

ldy #5 ; X is sprite data index
sta WSYNC ; wait for next scanline
sta WSYNC ; wait for next scanline

lvscan4
sta WSYNC ; wait for next scanline
lda colors+3
sta COLUP0
lda (current_player+6),y
sta GRP0 ; set sprite 0 pixels
lda (current_player+8),y
ldx.w colors+4
        SLEEP 20
sta GRP0
stx COLUP0
lda (current_player+10),y
ldx colors+5
sta GRP0
stx COLUP0
dey
bne lvscan4 ; repeat next scanline until finished

sty GRP0

ldx #0
        lda #LEFT_PLAYERS_XPOS
        jsr SetHorizPos


; Clear all colors to black before overscan
stx COLUP0
stx GRP0

ldx #145
footer
sta WSYNC ; wait for next scanline
dex
bne footer

; 30 lines of overscan
ldx #25
lvover
sta WSYNC
dex
bne lvover

jmp nextframe


; Subroutines !!

spacer
sta WSYNC ; wait for next scanline
dex
bne spacer
        rts

SetHorizPos
    ;call this function with A == horizontal position (0-159)
    ;and X == the object to be positioned (0=P0, 1=P1, 2=M0, etc.)
    ;if you do not wish to write to P1 during this function, make
    ;sure Y==0 before you call it.  This function will change Y, and A
    ;will be the value put into HMxx when returned.
    ;Call this function with at least 11 cycles left in the scanline
    ;(jsr + sec + sta WSYNC = 11); it will return 9 cycles
    ;into the second scanline
    sec
    sta WSYNC                        ;begin line 1
    sta.w HMCLR                        ;+4         4
DivideBy15Loop
    sbc #15
    bcs DivideBy15Loop                        ;+4/5        8/13.../58

    tay                                ;+2        10/15/...60
    lda FineAdjustTableEnd,Y        ;+5        15/20/...65

    ;        15
    sta HMP0,X        ;+4        19/24/...69
    sta RESP0,X        ;+4        23/28/33/38/43/48/53/58/63/68/73
    sta WSYNC        ;+3         0        begin line 2
    sta HMOVE        ;+3
    rts                ;+6         9

FineAdjustTableBegin
    .byte %01100000                ;left 6
    .byte %01010000
    .byte %01000000
    .byte %00110000
    .byte %00100000
    .byte %00010000
    .byte %00000000                ;left 0
    .byte %11110000
    .byte %11100000
    .byte %11010000
    .byte %11000000
    .byte %10110000
    .byte %10100000
    .byte %10010000
    .byte %10000000                ;right 8
FineAdjustTableEnd        =        (FineAdjustTableBegin - 241)


; Epilogue
org $fffc
.word start
.word start

JetSetIlly

I like the idea of using two rows to display a single hand. However, the cards on the second row being directly below the cards on the first row is visually confusing (at least to me). Have you tried offsetting the second row so the two rows are misaligned?
https://github.com/JetSetIlly/Gopher2600
@JetSetIlly@mastodon.gamedev.place
@jetsetilly.bsky.social

Al_Nafuur

Quote from: JetSetIlly on 14 Feb 2024, 12:50 AMI like the idea of using two rows to display a single hand. However, the cards on the second row being directly below the cards on the first row is visually confusing (at least to me). Have you tried offsetting the second row so the two rows are misaligned?

Maybe it would be better to use white playfield as background for the cards. Currently I use the playfield as the green table and a black COLUBK to hide the HMOVE stripes

Al_Nafuur

#8
Game start:


All players have 3 cards:


5 cards


Here is a Paintshoped! version how it might look like if we manage to use the playfield as background for the cards and add player1 to the status info:


Al_Nafuur

#9

        processor 6502
        include "vcs.h"
        include "macro.h"

LEFT_PLAYERS_XPOS = 18
RIGHT_PLAYERS_XPOS = 66

        org  $f000

colors                  equ $80 ; 5x6 = 30 bytes
current_color_pointer   equ $9E ; 2 bytes
cards_pointer           equ $A0 ; 5x12 = 60 bytes
player_counter          equ $DC ; 1 byte
                                ; 1 byte free
current_player_pointer  equ $DE ; 2 bytes
current_player          equ $E0 ; 12 byte
                                ; 4 bytes free
current_Color           equ $F0 ; 6 bytes

; Bitmap pattern for cards
CARD_ACE_CROSS
        .byte $00,$A7,$A2,$E2,$A7,$42
CARD_ACE_PIK
        .byte $00,$A7,$A2,$E7,$A7,$42
CARD_ACE_HEART
        .byte $00,$A0,$A2,$E7,$A7,$45
CARD_ACE_CARO
        .byte $00,$A0,$A2,$E7,$A7,$42

CARD_KING_CROSS
        .byte $00,$A7,$A2,$C2,$A7,$A2
CARD_KING_PIK
        .byte $00,$A7,$A2,$C7,$A7,$A2
CARD_KING_HEART
        .byte $00,$A0,$A2,$C7,$A7,$A5
CARD_KING_CARO
        .byte $00,$A0,$A2,$C7,$A7,$A2

CARD_10_CROSS
        .byte $00,$B7,$B2,$B2,$B7,$B2
CARD_10_PIK
        .byte $00,$B7,$B2,$B7,$B7,$B2
CARD_10_HEART
        .byte $00,$B0,$B2,$B7,$B7,$B5
CARD_10_CARO
        .byte $00,$B0,$B2,$B7,$B7,$B2

CARD_9_CROSS
        .byte $00,$E7,$22,$E2,$A7,$E2
CARD_9_PIK
        .byte $00,$E7,$22,$E7,$A7,$E2
CARD_9_HEART
        .byte $00,$E0,$22,$E7,$A7,$E5
CARD_9_CARO
        .byte $00,$E0,$22,$E7,$A7,$E2

CARD_1
        .byte $00,$22,$22,$22,$22,$22
CARD_2
        .byte $00,$EE,$88,$EE,$22,$EE
CARD_3
        .byte $00,$EE,$22,$66,$22,$EE
CARD_4
        .byte $00,$22,$22,$EE,$AA,$AA
CARD_5
        .byte $00,$EE,$22,$EE,$88,$EE
CARD_6
        .byte $00,$EE,$AA,$EE,$88,$EE
CARD_7
        .byte $00,$22,$22,$22,$22,$EE
CARD_8
        .byte $00,$EE,$AA,$EE,$AA,$EE
CARD_9
        .byte $00,$EE,$22,$EE,$AA,$EE

CARD_FACE_DOWN
        .byte $00,$FF,$AB,$D5,$AB,$FF
        .byte $00,$55,$AA,$55,$AA,$55

CARD_FREE
        .byte $00,$FF,$00,$00,$00,$00
CARD_BLANK
        .byte $00,$00,$00,$00,$00,$00

; Initialize and set initial offsets of objects.
start        CLEAN_START
        ldx #$00
        stx COLUBK        ; set the background color
        inx
        lda #RIGHT_PLAYERS_XPOS+8
        jsr SetHorizPos        ; set player 1 horiz. pos

        lda #6
        sta NUSIZ0        ; make player0 3 copies wide
        lda #0
        sta NUSIZ1        ; make player1 single copy
       
        lda #%1
        sta CTRLPF        ; set playfield mirror (move after stx COLUBK and inx ?)

        lda #$C2
        sta COLUPF
        lda #$C0
        sta PF0
        lda #$FF
        sta PF1
        sta PF2
;        sta GRP1
        lda #$0E
        sta COLUP1
       
; Load some valid pointers and colors for cards (PlusROM load later)
        lda #<CARD_FACE_DOWN
        sta cards_pointer
        lda #>CARD_FACE_DOWN
        sta cards_pointer+1
        lda #<CARD_ACE_PIK
        sta cards_pointer+2
        lda #>CARD_ACE_PIK
        sta cards_pointer+3
        lda #<CARD_5
        sta cards_pointer+4
        lda #>CARD_5
        sta cards_pointer+5
        lda #<CARD_KING_CROSS
        sta cards_pointer+6
        lda #>CARD_KING_CROSS
        sta cards_pointer+7
        lda #<CARD_ACE_HEART
        sta cards_pointer+8
        lda #>CARD_ACE_HEART
        sta cards_pointer+9
        lda #<CARD_10_CROSS
        sta cards_pointer+10
        lda #>CARD_10_CROSS
        sta cards_pointer+11

        lda #<CARD_4
        sta cards_pointer+12
        lda #>CARD_4
        sta cards_pointer+13
        lda #<CARD_KING_CROSS
        sta cards_pointer+14
        lda #>CARD_KING_CROSS
        sta cards_pointer+15
        lda #<CARD_FACE_DOWN
        sta cards_pointer+16
        lda #>CARD_FACE_DOWN
        sta cards_pointer+17
        lda #<CARD_ACE_CARO
        sta cards_pointer+18
        lda #>CARD_ACE_CARO
        sta cards_pointer+19
        lda #<CARD_ACE_CROSS
        sta cards_pointer+20
        lda #>CARD_ACE_CROSS
        sta cards_pointer+21
        lda #<CARD_KING_HEART
        sta cards_pointer+22
        lda #>CARD_KING_HEART
        sta cards_pointer+23

        lda #<CARD_FACE_DOWN
        sta cards_pointer+24
        lda #>CARD_FACE_DOWN
        sta cards_pointer+25
        lda #<CARD_ACE_PIK
        sta cards_pointer+26
        lda #>CARD_ACE_PIK
        sta cards_pointer+27
        lda #<CARD_1
        sta cards_pointer+28
        lda #>CARD_1
        sta cards_pointer+29
        lda #<CARD_ACE_CROSS
        sta cards_pointer+30
        lda #>CARD_ACE_CROSS
        sta cards_pointer+31
        lda #<CARD_KING_HEART
        sta cards_pointer+32
        lda #>CARD_KING_HEART
        sta cards_pointer+33
        lda #<CARD_9_CROSS
        sta cards_pointer+34
        lda #>CARD_9_CROSS
        sta cards_pointer+35

        lda #<CARD_9
        sta cards_pointer+36
        lda #>CARD_9
        sta cards_pointer+37
        lda #<CARD_ACE_CARO
        sta cards_pointer+38
        lda #>CARD_ACE_CARO
        sta cards_pointer+39
        lda #<CARD_FACE_DOWN
        sta cards_pointer+40
        lda #>CARD_FACE_DOWN
        sta cards_pointer+41
        lda #<CARD_KING_CROSS
        sta cards_pointer+42
        lda #>CARD_KING_CROSS
        sta cards_pointer+43
        lda #<CARD_ACE_CROSS
        sta cards_pointer+44
        lda #>CARD_ACE_CROSS
        sta cards_pointer+45
        lda #<CARD_KING_HEART
        sta cards_pointer+46
        lda #>CARD_KING_HEART
        sta cards_pointer+47

; colors (Clean start made $00 default color)
        lda #$80
        sta colors
        sta colors+8
        sta colors+12
        sta colors+20
        lda #$40
        sta colors+2
        sta colors+4
        sta colors+6
        sta colors+9
        sta colors+11
        sta colors+16
        sta colors+19
        sta colors+23
        lda $0E
        sta colors+2
        sta colors+6
        sta colors+14
        sta colors+18
; end of "loading"

        nop         ; padding so skip_pause in kernel don't cross page


; We've technically generated an invalid frame because
; these operations have generated superfluous WSYNCs.
; But it's just at the beginning of our program, so whatever.

; Next frame loop
nextframe
        VERTICAL_SYNC
       
        lda #$A0
        sta current_player_pointer
        lda #$80
        sta current_color_pointer

; 36 lines of VBLANK
        ldx #36
lvblank
        sta WSYNC
        dex
        bne lvblank

; Draw 192 scanlines
draw_a_player
        ldy #RIGHT_PLAYERS_XPOS
        lda player_counter
        and #1
        bne set_player_xpos
        ldy #LEFT_PLAYERS_XPOS
set_player_xpos
        tya
        jsr SetHorizPos        ; set player 0 horiz. pos

        ldy #5                 ; y is sprite data index
        sta WSYNC
        sta WSYNC
lvscan1
        sta WSYNC              ; wait for next scanline
        lda current_Color
        sta COLUP0
        lda (current_player),y
        sta GRP0               ; set sprite 0 pixels

        lda player_counter
        and #1
        beq skip_pause
        SLEEP 16
skip_pause
        lda (current_player+2),y
        ldx current_Color+1
        sta GRP0
        stx COLUP0
        lda (current_player+4),y
        ldx current_Color+2
        sta GRP0
        stx COLUP0
        dey
        bne lvscan1            ; repeat next scanline until finished

        sty GRP0

        ldx #4
        jsr spacer

        ldy #5                 ; y is sprite data index
lvscan2
        sta WSYNC              ; wait for next scanline
        lda current_Color+3
        sta COLUP0
        lda (current_player+6),y
        sta GRP0               ; set sprite 0 pixels
        lda player_counter
        and #1
        beq skip_pause2
        SLEEP 16
skip_pause2

        lda (current_player+8),y
        ldx current_Color+4
        sta GRP0
        stx COLUP0
        lda (current_player+10),y
        ldx current_Color+5
        sta GRP0
        stx COLUP0
        dey
        bne lvscan2            ; repeat next scanline until finished

        jmp prep_next_player

        sty GRP0

return_from_prep_next_player
        cmp #4
        bmi draw_a_player
        stx player_counter     ; x = 0 !



        ldx #71
footer
        sta WSYNC              ; wait for next scanline
        dex
        bne footer

; 30 lines of overscan
        ldx #25
lvover
        sta WSYNC
        dex
        bne lvover
       
        jmp nextframe


; Subroutines !!

prep_next_player
        sta WSYNC
        sty GRP0
        ldx #0
        lda #12
        adc current_player_pointer
        sta current_player_pointer
        lda #6
        adc current_color_pointer
        sta current_color_pointer
        inc player_counter
        lda player_counter
        jmp return_from_prep_next_player

spacer
        sta WSYNC        ; wait for next scanline
        dex
        bne spacer
        rts


SetHorizPos
;call this function with A == horizontal position (0-159)
;and X == the object to be positioned (0=P0, 1=P1, 2=M0, etc.)
;if you do not wish to write to P1 during this function, make
;sure Y==0 before you call it.  This function will change Y, and A
;will be the value put into HMxx when returned.
;Call this function with at least 11 cycles left in the scanline
;(jsr + sec + sta WSYNC = 11); it will return 9 cycles
;into the second scanline
        sec
        sta WSYNC                       ;begin line 1
        sta.w HMCLR                     ;+4         4
DivideBy15Loop
        sbc #15
        bcs DivideBy15Loop              ;+4/5        8/13.../58

        tay                             ;+2        10/15/...60
        lda FineAdjustTableEnd,Y        ;+5        15/20/...65

                                        ;        15
        sta HMP0,X                      ;+4        19/24/...69
        sta RESP0,X                     ;+4        23/28/33/38/43/48/53/58/63/68/73
        sta WSYNC                       ;+3         0        begin line 2
        sta HMOVE                       ;+3

; adding the copyroutine for the card pointer here
        ldy #11
copy_routine
        sta WSYNC        ; wait for next scanline
        lda (current_player_pointer),y
        sta current_player,y
        lda (current_color_pointer),y
        sta current_Color,y
        dey
        bpl copy_routine

        rts                ;+6         9

FineAdjustTableBegin
        .byte %01100000                ;left 6
        .byte %01010000
        .byte %01000000
        .byte %00110000
        .byte %00100000
        .byte %00010000
        .byte %00000000                ;left 0
        .byte %11110000
        .byte %11100000
        .byte %11010000
        .byte %11000000
        .byte %10110000
        .byte %10100000
        .byte %10010000
        .byte %10000000                ;right 8
FineAdjustTableEnd        =        (FineAdjustTableBegin - 241)


; Epilogue
        org $fffc
        .word start
        .word start


JetSetIlly

Out of curiosity, how much work is to connect to FujiNet?
https://github.com/JetSetIlly/Gopher2600
@JetSetIlly@mastodon.gamedev.place
@jetsetilly.bsky.social

Al_Nafuur

Quote from: JetSetIlly on 15 Feb 2024, 09:31 AMOut of curiosity, how much work is to connect to FujiNet?
I haven't really looked into it..

Most of the "work" will have to be done inside the PlusROM backend.

The lobby JSON can be loaded here: FujiNet Lobby

I think this can be easily converted to display with cd-w's text display I used in 1942 to load the HSC list:


For the communication with the game server I have to study the sources here:
https://github.com/FujiNetWIFI/servers/tree/main/5cardstud/server/mock-server


thom.cherryhomes

Hey, awesome! I didn't know this forum existed! :)

I'm the firmware engineer for FujiNet. :)

I'll be watching here. @Jeff Piepmeier is getting our device up (it just booted a 2K ROM yesterday), and as this comes together, i'll be jumping in to help. :)

-Thom

Andrew Davie

Quote from: thom.cherryhomes on 16 Feb 2024, 02:15 AMHey, awesome! I didn't know this forum existed! :)

Welcome!  Yes, it's a bit "hidden" - few people are mentioning it on AtariAge.

Andrew Davie

Quote from: Al_Nafuur on 14 Feb 2024, 05:56 AMHere is a Paintshoped! version how it might look like if we manage to use the playfield as background for the cards and add player1 to the status info:


I'm watching with interest!  Is there are reason the fonts and cards are so vertically squished?  They would look much better, IMHO, if they were at least double the height.