Now drawing clock hands, and inverting at night.

This commit is contained in:
Martin Haye 2018-01-04 10:36:21 -08:00
parent 887600efc9
commit 22dcfc8cd9

View File

@ -24,6 +24,10 @@ const CHAR_WND_HEALTH_X = 112
const ANIM_PAUSE_MAX = 300
const CLOCK_X = 112
const CLOCK_Y = 176
const CLOCK_RADIUS = 14
// Max gold
const GOLD_MAX = 20000
@ -378,6 +382,7 @@ asm _drawLine(color, len, xbyte, xbit, xinc, xdir, y, yinc, ydir)#0
eor (pTmp),y ; funny logic to plot in color - part 1
and .param_xbit,x ; bit mask within byte
eor (pTmp),y ; funny logic - part 2
and #$7F ; force low-bit colors for entire clock face (no mixing)
sta (pTmp),y ; store the result
lda .param_xbit,x ; check bit mask:
@ -1828,7 +1833,8 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
def horzSegment(color, len, x, y)#0
_drawLine(color, len, x/7, (3<<(x%7)) & $7F, $FF, 1, y, 0, 0)
//params: color, len, xbyte, xbit, xinc, xdir, y, yinc, ydir
_drawLine(color, len, x/7, (3<<(x%7)) & $7F, $FF, 1, y, 0, 0)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -1843,6 +1849,7 @@ def putSegment(color, len, isOuter, x, y)#0
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Draw a filled, outlined circle
def drawCircle(color, radius, x0, y0)#0
word x, y, dx, dy, err, r2, p
@ -1850,6 +1857,7 @@ def drawCircle(color, radius, x0, y0)#0
r2 = radius << 1
memset($280, 0, r2)
// Midpoint circle algorithm, but instead of plotting points, just record max extents
x = radius-1
y = 0
dx = 1
@ -1875,6 +1883,7 @@ def drawCircle(color, radius, x0, y0)#0
loop
// Using the extents, draw an outline circle
for y = 0 to radius-1
x = ^($280+y)
putSegment(color, x<<1, y>=radius-2, x0-x, y0-y)
@ -1882,6 +1891,69 @@ def drawCircle(color, radius, x0, y0)#0
next
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def drawHand(color, hour, isShort)#0
word xdir, xinc, ydir, yinc, len
ydir = (hour > 3 and hour < 9) & 1 // 3..9 = 1
xdir = (hour < 6) & 1 // 1..6 = 1
xinc = (^("123210123210"+hour) - '0') * 85
yinc = (^("210123210123"+hour) - '0') * 85
len = (hour % 3) ?? (CLOCK_RADIUS*3/2)-4 :: CLOCK_RADIUS-2
if isShort
len = len * 3 / 5
fin
//params: color, len, xbyte, xbit, xinc, xdir, y, yinc, ydir
_drawLine(color, len, CLOCK_X/7, (3<<(CLOCK_X%7)) & $7F, xinc, xdir, CLOCK_Y, yinc, ydir)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def drawHands(color, hour, min)#0
word n
n = min/5
drawHand(color, n ?? n :: 12, FALSE)
n = hour % 12
drawHand(color, n ?? n :: 12, TRUE)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def showClock()#0
word cursX, cursY, color, hour, min, n, prevColor
// Top, Bottom, Left, Right
cursX, cursY = getCursor()
setWindow(CLOCK_Y-CLOCK_RADIUS, CLOCK_Y+CLOCK_RADIUS, (CLOCK_X-CLOCK_RADIUS)/7*7, (CLOCK_X+CLOCK_RADIUS+6)/7*7)
prevColor = 99
hour = 0
min = 0
while TRUE
drawHands(color, hour, min) // erase
min = min + 5
if min > 59
min = min - 60
hour = hour + 1
if hour > 23
hour = 0
fin
fin
color = hour < 6 or hour >= 18 ?? 0 :: $7F
if color <> prevColor
drawCircle(color, CLOCK_RADIUS, CLOCK_X, CLOCK_Y)
prevColor = color
fin
drawHands(color ^ $7F, hour, min)
^$c054
rdkey()
loop
if mapIs3D and texturesLoaded; copyWindow(); fin
setWindow2()
setCursor(cursX, cursY)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def showCompassDir(dir)#0
word cursX, cursY, str
@ -1900,14 +1972,6 @@ def showCompassDir(dir)#0
wend
centerStr(str, 21)
if mapIs3D and texturesLoaded; copyWindow(); fin
// foo
setWindow(160, 192, 100, 140) // Top, Bottom, Left, Right
//clearWindow()
drawCircle(0, 12, 112, 177)
if mapIs3D and texturesLoaded; copyWindow(); fin
// normal
setWindow2()
setCursor(cursX, cursY)
end
@ -1969,11 +2033,13 @@ def initMap(x, y, dir)#0
curPortrait = NULL
curPortraitNum = 0
curFullscreenImg = NULL
if global->b_curAvatar <> 0 and !mapIs3D
if mapIs3D
showCompassDir(dir)
showClock()
elsif global->b_curAvatar <> 0
setAvatar(global->b_curAvatar)
doRender()
fin
if mapIs3D; showCompassDir(dir); fin
// Assume there might be animations until we learn otherwise
anyAnims = TRUE // for now; might get cleared if we discover otherwise on advance
@ -3281,14 +3347,6 @@ def startGame(ask)#0
crout()
end
def foo#0
setWindow(0, 192, 0, 280) // Top, Bottom, Left, Right
clearWindow()
drawCircle(100, 100, 50, $FF)
rdkey()
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Main code.
//