Added keys to rotate and move so you can wanter around BugTown. Crazy.

This commit is contained in:
Martin Haye 2013-08-30 13:22:56 -07:00
parent 98ec58291c
commit 25432cb16a
5 changed files with 158 additions and 795 deletions

File diff suppressed because it is too large Load Diff

View File

@ -126,6 +126,7 @@ class Segment:
elif c == '<':
outFile.write(" lsr\n")
else:
assert c < screenHeight
outFile.write(" sta %s*ROW_STRIDE + rowBlit,x\n" % c)
else:
if grouped:
@ -154,10 +155,12 @@ def makeCmds(dstHeight):
cmds = []
texOff = 0
if y0 < 0:
if y0 < 0 or y1 > screenHeight:
texOff += int((-y0/2) * srcHeight / dstHeight)
y0 = max(0, y0)
y1 = max(screenHeight/2, y1)
y1 = min(screenHeight, y1)
#print("Doing dstHeight=%d y0=%d y1=%d texOff=%d" % (dstHeight, y0, y1, texOff))
for y in range(y0, y1):
if b == 0:

View File

@ -160,6 +160,11 @@ function prepCast(angleNum, x)
var dirX = Math.cos(angle);
var dirY = Math.sin(angle);
if (x == 0)
console.log("angleNum=" + angleNum +
", dirX=" + wordToHex(uword((dirX*64) & 0xFFFF)) +
", dirY=" + wordToHex(uword((dirY*64) & 0xFFFF)));
// Compute the camera plane, which is perpendicular to the direction vector
var planeX = -Math.sin(angle) * 0.5;
var planeY = Math.cos(angle) * 0.5;

View File

@ -140,6 +140,26 @@ MIP_OFFSET_3 = $540 ; 32*32 + 16*16 + 8*8
MIP_OFFSET_4 = $550 ; 32*32 + 16*16 + 8*8 + 4*4
MIP_OFFSET_5 = $554 ; 32*32 + 16*16 + 8*8 + 4*4 + 2*2
; Movement amounts when walking at each angle
; Each entry consists of an X bump and a Y bump, in 8.8 fixed point
walkDirs:
.word $0040, $0000
.word $003B, $0018
.word $002D, $002D
.word $0018, $003B
.word $0000, $0040
.word $FFE8, $003B
.word $FFD3, $002D
.word $FFC5, $0018
.word $FFC0, $0000
.word $FFC5, $FFE8
.word $FFD3, $FFD3
.word $FFE8, $FFC5
.word $0000, $FFC0
.word $0018, $FFC5
.word $002D, $FFD3
.word $003B, $FFE8
; Debug macros
.macro DEBUG_STR str
.if DEBUG
@ -811,6 +831,7 @@ selectMip5:
drawRay:
; Make a pointer to the selected texture
ldx txNum
dex ; translate tex 1..4 to 0..3
lda texAddrLo,x
sta pTex
lda texAddrHi,x
@ -1186,8 +1207,8 @@ test:
sta resetVec+2
; Establish the initial player position and direction
; X=5.5
lda #5
; X=2.5
lda #2
sta playerX+1
lda #$80
sta playerX
@ -1375,16 +1396,87 @@ test:
lda kbd
bpl @pauseLup
sta kbdStrobe ; eat the keypress
cmp #$9B
beq @done
; advance
and #$7F
cmp #'w'
beq @forward
cmp #'W'
beq @forward
cmp #'s'
beq @backward
cmp #'S'
beq @backward
cmp #'x'
beq @backward
cmp #'X'
beq @backward
cmp #'a'
beq @left
cmp #'A'
beq @left
cmp #'d'
beq @right
cmp #'D'
beq @right
cmp #$1B
beq @done
jmp @pauseLup
@forward:
lda playerDir
asl
asl
tax
lda playerX
clc
adc #$40
adc walkDirs,x
sta playerX
bcc :+
inc playerX+1
: jmp @oneLevel
lda playerX+1
adc walkDirs+1,x
sta playerX+1
lda playerY
clc
adc walkDirs+2,x
sta playerY
lda playerY+1
adc walkDirs+3,x
sta playerY+1
jmp @oneLevel
@backward:
lda playerDir
asl
asl
tax
lda playerX
sec
sbc walkDirs,x
sta playerX
lda playerX+1
sbc walkDirs+1,x
sta playerX+1
lda playerY
sec
sbc walkDirs+2,x
sta playerY
lda playerY+1
sbc walkDirs+3,x
sta playerY+1
jmp @oneLevel
@left:
dec playerDir
lda playerDir
cmp #$FF
bne :+
lda #15
: sta playerDir
jmp @oneLevel
@right:
inc playerDir
lda playerDir
cmp #16
bne :+
lda #0
: sta playerDir
jmp @oneLevel
@done:
bit setText
bit page1