New way of displaying the Nyan Timer

This commit is contained in:
Leurak 2017-04-29 12:50:32 +02:00
parent f886a2fb5a
commit b4c7132a44
9 changed files with 62 additions and 44 deletions

View file

@ -1,5 +1,4 @@
import sys, math, struct, os
#from io import BytesIO
from PIL import Image
doscolors = [
@ -42,9 +41,14 @@ for imgf in sys.argv[1:-1]:
for y in xrange(0, h, 2):
for x in xrange(w):
b = (nearest_color(img.getpixel((x, y))) << 4) | nearest_color(img.getpixel((x, y+1)))
buf += chr(b)
b = (nearest_color(img.getpixel((x, y))) << 4)
if y < 48 or x >= len("You've Nyaned for 00000.0 seconds!"):
b |= nearest_color(img.getpixel((x, y+1)))
else:
b |= 15 if ((b>>4) < 8) else 0
buf += chr(b)
img.close()
with open(sys.argv[::-1][0], "wb") as out:

View file

@ -24,10 +24,10 @@ dir: $(BUILDDIR)
$(BUILDDIR):
mkdir -p $(BUILDDIR)
$(BUILDDIR)/frames.bin: $(FRAMES)
$(BUILDDIR)/frames.bin: $(FRAMES) Data/Image/png2bin.py
$(PY) Data/Image/png2bin.py $(FRAMES) $@
$(BUILDDIR)/special.bin: $(SPECIAL)
$(BUILDDIR)/special.bin: $(SPECIAL) Data/Image/png2bin.py
$(PY) Data/Image/png2bin.py $(SPECIAL) $@
$(BUILDDIR)/song.bin: $(MUSIC)

View file

@ -12,17 +12,15 @@ drawNormalFrame:
; Display the frame
.displayFrame:
mov ah, 220 ; Set the block character to use
mov di, 1 ; Offset one byte
mov cx, frameSize
.draw:
lodsb
stosw
stosb
inc di
loop .draw
mov [cs:frameIndex], si
call drawNyanCounter
.end: ret

View file

@ -1,14 +0,0 @@
drawNyanCounter:
mov di, 80*48
mov si, nyanTimeStart
mov cx, nyanTimeLenFull
mov bx, 0
.loop:
lodsb
mov ah, 0x1f
stosw
loop .loop
.end: ret

View file

@ -0,0 +1,20 @@
initDrawing:
setVideoMemory
mov di, 0
mov ax, 0x00DC
mov cx, nyanTimeVideoStart/2
rep stosw
mov cx, nyanTimeStringLen
mov si, nyanTimeString
.initNyanTime:
lodsb
stosw
loop .initNyanTime
mov al, 0xDC
mov cx, frameSize - nyanTimeVideoStart/2 - nyanTimeStringLen
rep stosw
ret

View file

@ -1,20 +1,20 @@
nyanTimeStart: db "You Nyaned for "
nyanTime: db "000000.0"
nyanTimeLen equ $-nyanTime
nyanTimeEnd: db " seconds!"
nyanTimeLenFull equ $-nyanTimeStart
nyanTimeString: db "You've Nyaned for 00000.0 seconds!"
nyanTimeStringLen: equ $-nyanTimeString
nyanTimeVideoStart: equ 3840
nyanTimeBin dw 0
countNyan:
setVideoMemory
inc word [cs:nyanTimeBin]
mov bx, nyanTimeLen
mov bx, nyanTimeStringLen*2
.loop:
dec bx
sub bx, 2
mov al, [cs:nyanTime+bx]
mov al, [es:nyanTimeVideoStart+bx]
cmp al, '0'
jb .next
@ -22,13 +22,13 @@ countNyan:
ja .next
inc al
mov [cs:nyanTime+bx], al
mov [es:nyanTimeVideoStart+bx], al
cmp al, '9'+1
jne .end
mov al, '0'
mov [cs:nyanTime+bx], al
mov [es:nyanTimeVideoStart+bx], al
.next:
cmp bx, 0

View file

@ -3,12 +3,6 @@ frameIndex dw 0
frameSize: equ (80*50) / 2 ; Raw binary size of a frame
lastFrame: equ special
%macro setVideoMemory 0
; Set the extra segment to video memory
mov cx, 0xb800
mov es, cx
%endmacro
displayFrame:
setVideoMemory
@ -24,6 +18,13 @@ displayFrame:
; Reset the frame index when the intro is done
mov si, frames
; Revert the message characters
mov di, 0
mov cx, messageLength
mov ax, 0x00DC
rep stosw
jmp .normalFrame
; Intro Frame
@ -42,6 +43,6 @@ displayFrame:
.end: ret
%include "Animation/Image/initDrawing.asm"
%include "Animation/Image/drawIntroFrame.asm"
%include "Animation/Image/drawNormalFrame.asm"
%include "Animation/Image/drawNyanCounter.asm"

View file

@ -18,3 +18,6 @@ mov sp, 0x2000
; Setup the PC speaker
%include "Setup/setupSpeaker.asm"
; Setup the screen and Nyan Counter
call initDrawing

View file

@ -20,3 +20,9 @@
mov word [es:(%1+8)*4], %2 ; Interrupt Handler
mov word [es:(%1+8)*4+2], 0 ; Segment 0x0000
%endmacro
%macro setVideoMemory 0
; Set the extra segment to video memory
mov cx, 0xb800
mov es, cx
%endmacro