Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Multiplexing sprites?
2016-06-02 19:02
Rudi
Account closed

Registered: May 2010
Posts: 125
Multiplexing sprites?

Hi,
Thanks for all the help ive gotten so far here on csdb.
Now I've runned into another problem.
How the *** does sprite multiplexing work?
I just need the basic idea. I tried to read Cadaver and other tuts, but they seemed too advanced for my taste in continuing.

What my goal is basically to display 64 sprites that stands still. So it will display a checkerboard, hence the sprites only need one of two colors. and they are filled with either of the color. The sprites are displayed beneath the characters so i can either have black and white chess-pieces (using $d800) this works fine with 8 sprites! but now i need to fill the entire checkerboard.
(edit: the entire board is in singlecolor, not multicolor btw)

I have not yet figured out how it works in theory? I just need to have interrupts on each row and display the sprites.
I have a feeling it would work something like this:

01234567
12345670
01234567
12345670
01234567
12345670
01234567
12345670

sprite 0 has darkgray, sprite 1 gray color, sprite 2 darkgray, ..etc.. so it will show a checkerboard in the end..
is it as simple as just setting an interrupt and move the sprite or do one need something else to take into consideration as well?
 
... 42 posts hidden. Click here to view all posts....
 
2016-06-04 06:53
Rudi
Account closed

Registered: May 2010
Posts: 125
Skate: Thats an excelent idea.

TWW: Nice description. I wasn't going to actually make a game yet, only an chess-animation for intro to a demo, or else I would never be able to make enough stuff for a demo for X. Maybe i'll be hooked and make a game afterall, haha - But who knows. I might get bored if things start to get tricky anyway.
2016-06-04 07:02
JackAsser

Registered: Jun 2002
Posts: 1989
I thought implementing the AI was the tricky part! ;)
2016-06-04 16:07
Rudi
Account closed

Registered: May 2010
Posts: 125
JackAsser: When I wrote the AI for https://sites.google.com/site/rudibstranden/projects/chess-obse.. the tricky part was the En Passant and the special cases for castling.

I guess there might be some special logical (boolean) rules from a bitboard if its set up correctly, so one can reduce code. So that it dont get too massive for 6502/6510 code.
2016-06-04 16:25
JackAsser

Registered: Jun 2002
Posts: 1989
Quote: JackAsser: When I wrote the AI for https://sites.google.com/site/rudibstranden/projects/chess-obse.. the tricky part was the En Passant and the special cases for castling.

I guess there might be some special logical (boolean) rules from a bitboard if its set up correctly, so one can reduce code. So that it dont get too massive for 6502/6510 code.


Can imagine! :)
2016-06-04 17:42
TWW

Registered: Jul 2009
Posts: 541
Hehe Yeah sure, it's piece of cake ;-)

If You set up the Board in ZP as described above and mark the pieces With identifying bits informing if they have been moved before or not, You only need to define the rules and here are some examples for pawns and Rooks/King:

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CheckLegalPawn:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RULES:
~~~~~~
Vertical+1:      Pos+8
Vertical+2:      Pos+16         <--- Only when virgin
CapDia+1:        Pos+7
CapDia+1:        Pos+9
En Passant:      Pos+7          <--- Only when adjacent to fresh pawn opponent (Pos+16)
En Passant:      Pos+9          <--- Only when adjacent to fresh pawn opponent (Pos+16)
Upgrade:         Pos = last line (0-7 / 56-63)


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CheckLegalRook:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RULES:
~~~~~~
Vertical:   Pos+8 x [1-8]
Vertical:   Pos-8 x [1-8]
Horizontal: Pos+1->8
Horizontal: Pos-1->8
Castling:   Pos+2      <--- Only when K & R are virgin
Castling:   Pos-3      <--- Only when K & R are virgin

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CheckLegalKing:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

RULES:
~~~~~~
Pos+1 & Pos-1
pos+7 & pos-7
Pos+8 & Pos-8
pos+9 & pos-9
Castling: Pos-2          <--- Only when K & R are virgin
Castling: Pos+3          <--- Only when K & R are virgin
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/


Implementing this in code is not very complicated.

Then You off course need check that the slope(s) are Clear:

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Checks the path between the two horizontal Squares
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

HorizontalLineClearCheck:

    // Find number of squares to check
    lda OldSquare
    sec
    sbc SelectedSquare
    bcs !+
      eor #$ff
      adc #$01
!:  tax

    // Find signed parameter to use in the slope checker
    lda OldSquare
    cmp SelectedSquare
    bcc !+
    lda #$ff
    jmp CheckSlope
!:  lda #$01
    jmp CheckSlope

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Checks the path between the two vertical squares
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

VerticalLineClearCheck:
    // Find number of squares between the squares (absolute)
    lda OldSquare
    sec
    sbc SelectedSquare
    bcs !+
      eor #$ff
      adc #$01
!:  lsr
    lsr
    lsr        // Divide the difference with 8
    tax

    // Find signed parameter to use in the slope checker
    lda OldSquare
    cmp SelectedSquare
    bcc !+
    lda #$f8
    jmp CheckSlope
!:  lda #$08
    jmp CheckSlope

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Checks the path between the two diagonal squares
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

DiagonalLineClearCheck:

    // Check if the move is left or right
    lda OldSquare
    and #%00000111
    sta $02
    lda SelectedSquare
    and #%00000111
    sec
    sbc $02
    bcs !Left+
        eor #$ff
        adc #$01
!Right:  // XPOS SelectedSquare > OldSquare
    tax  // Number of squares to check in X-REG

    // Find if move is up or down
    lda OldSquare
    cmp SelectedSquare
    bcs !RightUp+
!RightDown:
    lda #$07
    jmp CheckSlope
!RightUp:
    lda #$f7
    jmp CheckSlope

!Left:   // XPOS OldSquare > SelectedSquare
    tax  // Number of squares to check in X-REG

    // Find if move is up or down
    lda OldSquare
    cmp SelectedSquare
    bcs !LeftUp+
!LeftDown:
    lda #$09
    jmp CheckSlope
!LeftUp:
    lda #$f9
    jmp CheckSlope


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Routine for checking if squares between two points are empty
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Parameters:
//   A- $02 - Loaded with Signed byte for slopecheck:
//     #$01 - Horizontal Right
//     #$ff - Horizontal Left     
//     #$08 - Vertical Down
//     #$f8 - Vertical Up
//     #$07 - Diagonal Down-Left
//     #$09 - Diagonal Down-Right
//     #$f9 - Diagonal Up-Right
//     #$f7 - Diagonal Up-Left
//  X-Reg - Squares to check
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CheckSlope:
    sta $02    // Parameter = Signed number for slope check

    dex        // Decrease with one square to check
    beq !end+  // If already zero, there was no squares to check

    // Find first square to check
    lda OldSquare
    clc
    adc $02    // Skip first square since it's occupied by the piece in oldsquare
    tay

!loop:
    lda $40,y  // Fetch Square,Y
    beq !+
        sec
        rts
!:  tya
    clc
    adc $02
    tay
    dex
    bne !loop-
!end:
    clc
    rts


Also not any rocket science.

You off course need to check if target cell is legal and if it's occupied to determine legal moves (including putting onself in chess). There are also some rules in regards to stalemate situations.

Once all the rules are defined, the Next step is the AI. This is off course the most complicated but not neccessarely as the AI has to play by the same rules defined for the game. A chess game is split up into 3 parts, the opening game, mid game and end game. Opening game, one could store 3,4,5,6.. known openings and also verify there are no cheap shots by the player along the way. then mid game it's conquer the middle Field along With valuing the pieces to determine if You should capture or not/fortify. Then for end game it Depends the score if AI should try to Draw or position for chess mate. Then You can add the complexity and also plan moves Ahead (which could be set by an dificulty setting). The only real limitation here is memory whic should be no problem considering the early chess computer games and the maount of memory available there...

Perhaps this would be a good thought for the next C64 compo, to make the smartest AI for a chessgame ;-)
2016-06-04 17:57
Oswald

Registered: Apr 2002
Posts: 5017
TWW, yeah that is like a texturemap tutorial like this: well just rotate the vertices in 3d should be simple, then interpolate uv's along the edges, then across the scanline. phong should be a piece of cake after that ;)
2016-06-04 18:51
TWW

Registered: Jul 2009
Posts: 541
It been done before (like when I was born before) and in really short Versions too:

http://www.6502.org/source/games/uchess/uchess.htm

Anyhu, just wanted to give some ideas.
2016-06-05 05:49
Oswald

Registered: Apr 2002
Posts: 5017
Quote: It been done before (like when I was born before) and in really short Versions too:

http://www.6502.org/source/games/uchess/uchess.htm

Anyhu, just wanted to give some ideas.


you are way off topic with all this here.
2016-06-05 11:34
TWW

Registered: Jul 2009
Posts: 541
Yes, indeed. This was about sprite multiplexing.
2016-06-06 14:24
Rudi
Account closed

Registered: May 2010
Posts: 125
Quote: you are way off topic with all this here.

Thats not his fault tho. :P
Seemed I didnt need sprites for this at all. So Ill take the blame for being off topic.
I could have changed the topic-header if that was possible..
Previous - 1 | 2 | 3 | 4 | 5 | 6 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Genius/Xenon
Mike
Soya/Fairlight
fieserWolF/Abyss-Con..
Mr. SID
Viti/Hokuto Force
Didi/Laxity
Guests online: 134
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Bromance  (9.6)
10 Memento Mori  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.051 sec.