Transfer sprite-related constants and tables to 6502 code.

This commit is contained in:
Martin Haye 2013-11-10 09:13:33 -08:00
parent 229951d2e0
commit 858973dc68
2 changed files with 45 additions and 20 deletions

View File

@ -105,6 +105,10 @@ var overlay;
var fps = 0;
var overlayText = "";
// Constants
var wLog256;
var wLogViewDist;
// Tables
var precastData = [];
var tbl_log2_b_b = null;
@ -252,6 +256,10 @@ function initCast()
for (i=0; i<256; i++)
tbl_pow2_w_w[i] = ubyte((Math.pow(2, i / 255) - 1) * 255);
// Sprite math constants
wLog256 = log2_w_w(256);
wLogViewDist = log2_w_w(viewDist/8*256); // div by 8 to get to Apple II coords
// Sine table
tbl_wLogSin = [];
for (i=0; i<16; i++) {
@ -340,6 +348,15 @@ function printPrecast() {
}
console.log(" .res 4 ; to bring it up to 256 bytes per angle");
}
console.log("");
console.log("wLog256: .word " + wordToHex(wLog256));
console.log("wLogViewDist: .word " + wordToHex(wLogViewDist));
console.log("");
console.log("sinTbl:");
for (var i=0; i<maxAngleNum; i++)
console.log(" .word " + wordToHex(tbl_wLogSin[i]));
}
function printTbl(arr) {

View File

@ -26,26 +26,6 @@ MAX_TEXTURES = 20
texAddrLo: .res MAX_TEXTURES
texAddrHi: .res MAX_TEXTURES
; 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
@ -2589,3 +2569,31 @@ precast_15:
.byte $7E,$07,$05,$56
.res 4 ; to bring it up to 256 bytes per angle
wLog256: .word 0800
wLogViewDist: .word 0E3F
; 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
; Sin of each angle, in log8.8 format plus the high bit being the sign (0x8000 = negative)
sinTbl:
.word $0000, $8699, $877F, $87E1, $8800, $87E1, $877F, $8699
.word $8195, $0699, $077F, $07E1, $0800, $07E1, $077F, $0699