Jump to content
IGNORED

Padawan seeks Jedi Master!


Recommended Posts

Hello friends...

 

I have had DASM working for five days now, and have "finished" coding my first playfield using Andrew's tutorials/code. I'm still playing with the colors and shape of the center circle, but that's just cleanup.

 

I would like someone to take a look at the code and tell me what I need to do differently. I'm sure there is an easier way (and more efficient) of drawing the playfield than listing it out line by line (for instance writing a loop) because I don't seem to find the same thing in other code I look at. At first I was trying it with 24 (the number of vertical pixels available in the playfield?) but ended up needing to draw out each of the 192 scanlines for it to work right. Still I'm pretty happy for having been coding for all of four days now (I finished this last night, just now getting around to posting).

 

Also, as I (mistakingly) posted in the homebrew forum, I want to try and program a dodgeball game. There are several games I would be interested in seeing the code for, yet am unable to find code for any sports games at all (ie- basketball, volleyball, football). Is this available anywhere? I also don't suppose it's possible to take binaries and turn them into assemblies at all?

 

I would really like to have a 3 on 3 game where the sprites move independent of one another and you can switch between them as you choose (ala Super Tecmo Bowl wide receivers). I am however willing to settle for 2 on 2 with the players locked together if that isn't possible. I have also played with some code from the sprites tutorials, but can't seem to get any of it to compile correctly. My biggest problem is that I'm quickly running out of information to absorb, as there are only 24 tutorials and I still need to know about stuff like collisions, restricting sprites to half the court, etc. I'm hoping I have the potential for a high midichlorian count... any Jedi seeking a padawan (located in KC, MO) to train?

 

By the way, much kudos to Andrew Davie- I'm sure it's helped many people have the capacity to begin coding, even if just for hacking. :!: :thumbsup:

 

-JD

Link to comment
Share on other sites

Okay, it didn't include the attachment for some reason... trying again.

 

-JD

 

Apparently, .s files are not supported...though I didn't get that message the first time. I don't have WinZip ready, so I'lll just post the actual code below.

 

; Dodgeball Playfield Code

; 3/14/05

 

processor 6502

include "vcs.h"

include "macro.h"

 

SEG

ORG $F000

 

Reset

; Clear RAM, TIA registers and Set Stack Pointer to #$FF

SEI

CLD

LDX #$FF

TXS

LDA #0

Clear_Mem

STA 0,X

DEX

BNE Clear_Mem

 

LDA #$A4 ; Load Color

STA COLUBK ; Set Background Color

LDA #$1F ; Load Color

STA COLUPF ; Set Playfield Color

LDA #%00000001 ; Mirrored Playfield

STA CTRLPF

 

Start_Frame

 

; Start VSYNC

 

LDA #2

STA VSYNC

 

STA WSYNC

STA WSYNC

STA WSYNC ; 3 Scanlines of VSYNC

 

LDA #0

STA VSYNC ; End VSYNC

 

 

; 37 Scanlines of Vertical Blank

 

LDX 37

Vertical_Blank STA WSYNC

DEX

BNE Vertical_Blank

 

LDA #0

STA VBLANK ; Enable TIA Output

 

LDX #192 ; 192 Scanlines to Display

Draw_Picture

LDA Screen_PF0-1,X

STA PF0

LDA Screen_PF1-1,X

STA PF1

LDA Screen_PF2-1,X

STA PF2

STA WSYNC

DEX

BNE Draw_Picture

 

 

LDA #%01000010 ; Disable VIA Output

STA VBLANK

 

; 30 overscan lines

 

LDX #30

Overscan STA WSYNC

DEX

BNE Overscan

 

JMP Start_Frame ; Build Next Frame

 

; Mirrored Playfields generated = PF0, PF1, PF2

 

Screen_PF0

.byte #%11111111

.byte #%11111111

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%00010000

.byte #%11111111

.byte #%11111111

 

Screen_PF1

.byte #%11111111

.byte #%11111111

.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

.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

.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 #%11111111

.byte #%11111111

 

Screen_PF2

.byte #%11111111 ;1

.byte #%11111111 ;2

.byte #%10000000 ;3

.byte #%10000000 ;4

.byte #%10000000 ;5

.byte #%10000000 ;6

.byte #%10000000 ;7

.byte #%10000000 ;8

.byte #%10000000 ;9

.byte #%10000000 ;10

.byte #%10000000 ;11

.byte #%10000000 ;12

.byte #%10000000 ;13

.byte #%10000000 ;14

.byte #%10000000 ;15

.byte #%10000000 ;16

.byte #%10000000 ;17

.byte #%10000000 ;18

.byte #%10000000 ;19

.byte #%10000000 ;20

.byte #%10000000 ;21

.byte #%10000000 ;22

.byte #%10000000 ;23

.byte #%10000000 ;24

.byte #%10000000 ;25

.byte #%10000000 ;26

.byte #%10000000 ;27

.byte #%10000000 ;28

.byte #%10000000 ;29

.byte #%10000000 ;30

.byte #%10000000 ;31

.byte #%10000000 ;32

.byte #%10000000 ;33

.byte #%10000000 ;34

.byte #%10000000 ;35

.byte #%10000000 ;36

.byte #%10000000 ;37

.byte #%10000000 ;38

.byte #%10000000 ;39

.byte #%10000000 ;40

.byte #%10000000 ;41

.byte #%10000000 ;42

.byte #%10000000 ;43

.byte #%10000000 ;44

.byte #%10000000 ;45

.byte #%10000000 ;46

.byte #%10000000 ;47

.byte #%10000000 ;48

.byte #%10000000 ;49

.byte #%10000000 ;50

.byte #%10000000 ;51

.byte #%10000000 ;52

.byte #%10000000 ;53

.byte #%10000000 ;54

.byte #%10000000 ;55

.byte #%10000000 ;56

.byte #%10000000 ;57

.byte #%10000000 ;58

.byte #%10000000 ;59

.byte #%10000000 ;60

.byte #%10000000 ;61

.byte #%10000000 ;62

.byte #%10000000 ;63

.byte #%10000000 ;64

.byte #%10000000 ;65

.byte #%10000000 ;66

.byte #%10000000 ;67

.byte #%10000000 ;68

.byte #%10000000 ;69

.byte #%10000000 ;70

.byte #%11000000 ;71

.byte #%11000000 ;72

.byte #%11000000 ;73

.byte #%11000000 ;74

.byte #%10110000 ;75

.byte #%10110000 ;76

.byte #%10110000 ;77

.byte #%10110000 ;78

.byte #%10001000 ;79

.byte #%10001000 ;80

.byte #%10001000 ;81

.byte #%10001000 ;82

.byte #%10000100 ;83

.byte #%10000100 ;84

.byte #%10000100 ;85

.byte #%10000100 ;86

.byte #%10000100 ;87

.byte #%10000100 ;88

.byte #%10000100 ;89

.byte #%10000100 ;90

.byte #%10000010 ;91

.byte #%10000010 ;92

.byte #%10000010 ;93

.byte #%10000010 ;94

.byte #%10000010 ;95

.byte #%10000010 ;96

.byte #%10000010 ;97

.byte #%10000010 ;98

.byte #%10000010 ;99

.byte #%10000010 ;100

.byte #%10000010 ;101

.byte #%10000010 ;102

.byte #%10000100 ;103

.byte #%10000100 ;104

.byte #%10000100 ;105

.byte #%10000100 ;106

.byte #%10000100 ;107

.byte #%10000100 ;108

.byte #%10001000 ;109

.byte #%10001000 ;110

.byte #%10001000 ;111

.byte #%10001000 ;112

.byte #%10110000 ;113

.byte #%10110000 ;114

.byte #%10110000 ;115

.byte #%10110000 ;116

.byte #%11000000 ;117

.byte #%11000000 ;118

.byte #%11000000 ;119

.byte #%11000000 ;120

.byte #%10000000 ;121

.byte #%10000000 ;122

.byte #%10000000 ;123

.byte #%10000000 ;124

.byte #%10000000 ;125

.byte #%10000000 ;126

.byte #%10000000 ;127

.byte #%10000000 ;128

.byte #%10000000 ;129

.byte #%10000000 ;130

.byte #%10000000 ;131

.byte #%10000000 ;132

.byte #%10000000 ;133

.byte #%10000000 ;134

.byte #%10000000 ;135

.byte #%10000000 ;136

.byte #%10000000 ;137

.byte #%10000000 ;138

.byte #%10000000 ;139

.byte #%10000000 ;140

.byte #%10000000 ;141

.byte #%10000000 ;142

.byte #%10000000 ;143

.byte #%10000000 ;144

.byte #%10000000 ;145

.byte #%10000000 ;146

.byte #%10000000 ;147

.byte #%10000000 ;148

.byte #%10000000 ;149

.byte #%10000000 ;150

.byte #%10000000 ;151

.byte #%10000000 ;152

.byte #%10000000 ;153

.byte #%10000000 ;154

.byte #%10000000 ;155

.byte #%10000000 ;156

.byte #%10000000 ;157

.byte #%10000000 ;158

.byte #%10000000 ;159

.byte #%10000000 ;160

.byte #%10000000 ;161

.byte #%10000000 ;162

.byte #%10000000 ;163

.byte #%10000000 ;164

.byte #%10000000 ;165

.byte #%10000000 ;166

.byte #%10000000 ;167

.byte #%10000000 ;168

.byte #%10000000 ;169

.byte #%10000000 ;170

.byte #%10000000 ;171

.byte #%10000000 ;172

.byte #%10000000 ;173

.byte #%10000000 ;174

.byte #%10000000 ;175

.byte #%10000000 ;176

.byte #%10000000 ;177

.byte #%10000000 ;178

.byte #%10000000 ;179

.byte #%10000000 ;180

.byte #%10000000 ;181

.byte #%10000000 ;182

.byte #%10000000 ;183

.byte #%10000000 ;184

.byte #%10000000 ;185

.byte #%10000000 ;186

.byte #%10000000 ;187

.byte #%10000000 ;188

.byte #%10000000 ;189

.byte #%10000000 ;190

.byte #%11111111 ;191

.byte #%11111111 ;192

 

 

ORG $FFFA

 

; Interrupt Vectors

 

.word Reset ; NMI

.word Reset ; RESET

.word Reset ; IRQ

 

END

Link to comment
Share on other sites

Hello,

 

Glad to see new people trying their hand at programming thte VCS. Please use Winzip in the future. That big listing of PF data is painful to scroll through on the forum.

 

Here is the main visible display loop from your code above:


LDX #192; 192 Scanlines to Display 

Draw_Picture 

LDA Screen_PF0-1,X 

STA PF0 

LDA Screen_PF1-1,X 

STA PF1 

LDA Screen_PF2-1,X 

STA PF2 

STA WSYNC 

DEX 

BNE Draw_Picture 

 

If you want to reduce that size of your PF data tables, then you can employ many methods. The key to many of them is to use one index register to count the total scanlines (X in your code) and the other index register to point at the next byte of PF data. If the PF data should be recycled for say 8 scanlines producing PF pixels 8 scanlines high and cutting your tables by 8, then you simply need to update Y only once every 8 lines. like this:

 


LDX #192; 192 Scanlines to Display

LDY #0    ; PF Graphics index. 

Draw_Picture 

LDA Screen_PF0-1,Y 

STA PF0 

LDA Screen_PF1-1,Y 

STA PF1 

LDA Screen_PF2-1,Y 

STA PF2 

STA WSYNC 

DEX 

BEQ exit



TXA   ; Copy the line count to A

AND  #8-1 ; Since 8 is a power of 2 we can test the lower 3 bits of

BNE .skip1 ; the line count. If they are all 0's, then the line count is

INY           ; a mulitple of 8 and we need to increment the PF index in Y

.skip1

JMP Draw_Picture 

 

You need to learn how to use the timer TIM64T and INTIM to count scanlines, and you will find it easier to write a display loop if you do not try to use all 192 lines. Its hard to make a graceful transition from vertical blanking directly to a loop that draws the screen. If you leave the first visible scanline blank, then you can move the STA WSYNC to the top of your display loop, and then the sequence of code in the loop from top to bottom matches the scanning of the raster on the TV from left to right for one scanline. I think you will find that arrangement easier to manage and solve display problems.

 

As for displaying 6 sprites on the screen, the Venture game that I disassembled to hack into Wolfenstein has an engine that can display 6 sprites and the ball with veritcal placement restrictions and flickering at 30 Hz. The mostly commented source is located here: http://www.qotile.net/minidig/

 

There is alot of other good info and source code examples at the minidig.

 

Cheers!

Link to comment
Share on other sites

I second what Robert said, and will add that Kirk Israel's tutorial is very well written and pretty helpful for some of the stuff you mentioned (sprites, etc.).

 

It also has very thoroughly commented code for working, complete programs that is helpful in setting up your own programs to, for example, have stable main loops.

 

Tutorial here: http://www.alienbill.com/2600/101/

 

And don't forget the Stella mailing list archives.

http://www.biglist.com/lists/stella/archives/

 

Oh, and another way to cut down on PF data which I find simpler (but that's just cuz I'm a little slow) is this:

   ldx #24

LoopOuter

  ldy #8

LoopInner

  sta WSYNC

  lda Screen_PF0-1,X

  sta PF0

  lda Screen_PF1-1,X

  sta PF1

  lda Screen_PF2-1,X

  sta PF2

  dey

  bne LoopInner

  dex

  bne LoopOuter

That will also draw 192 scanlines of PF in 8-line chunks.

 

Of course, the best way, if you are doing this, is to only draw the PF when it changes, since TIA will keep drawing the same thing on every line if you don't tell it different. Something like...

   ldx #24

LoopOuter

  sta WSYNC

  lda Screen_PF0-1,X

  sta PF0

  lda Screen_PF1-1,X

  sta PF1

  lda Screen_PF2-1,X

  sta PF2

  ldy #7

LoopInner

  sta WSYNC

  dey

  bne LoopInner

  dex

  bne LoopOuter

Ok, I'm done now :)

Link to comment
Share on other sites

Oh, and another way to cut down on PF data which I find simpler (but that's just cuz I'm a little slow) is this:

Yup, that's simplier. But once you want to draw sprites it is better to have Y as a scanline counter.

 

For blocksizes which are not a power of 2, something like this does the job


 ldy #191

.loop:

 ...

 dey

 tya                     ; I wish cpy abs,x would exist

 cmp BlockSizeTbl,x

 bne .loop

 dex

 bpl .loop

 ...



BlockSizeTbl:

 .byte 0, 27, 50, 60, 147, 180

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