New way of displaying the Nyan Timer
This commit is contained in:
parent
f886a2fb5a
commit
b4c7132a44
9 changed files with 62 additions and 44 deletions
|
@ -1,5 +1,4 @@
|
||||||
import sys, math, struct, os
|
import sys, math, struct, os
|
||||||
#from io import BytesIO
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
doscolors = [
|
doscolors = [
|
||||||
|
@ -42,9 +41,14 @@ for imgf in sys.argv[1:-1]:
|
||||||
|
|
||||||
for y in xrange(0, h, 2):
|
for y in xrange(0, h, 2):
|
||||||
for x in xrange(w):
|
for x in xrange(w):
|
||||||
b = (nearest_color(img.getpixel((x, y))) << 4) | nearest_color(img.getpixel((x, y+1)))
|
b = (nearest_color(img.getpixel((x, y))) << 4)
|
||||||
buf += chr(b)
|
|
||||||
|
|
||||||
|
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()
|
img.close()
|
||||||
|
|
||||||
with open(sys.argv[::-1][0], "wb") as out:
|
with open(sys.argv[::-1][0], "wb") as out:
|
||||||
|
|
|
@ -24,10 +24,10 @@ dir: $(BUILDDIR)
|
||||||
$(BUILDDIR):
|
$(BUILDDIR):
|
||||||
mkdir -p $(BUILDDIR)
|
mkdir -p $(BUILDDIR)
|
||||||
|
|
||||||
$(BUILDDIR)/frames.bin: $(FRAMES)
|
$(BUILDDIR)/frames.bin: $(FRAMES) Data/Image/png2bin.py
|
||||||
$(PY) Data/Image/png2bin.py $(FRAMES) $@
|
$(PY) Data/Image/png2bin.py $(FRAMES) $@
|
||||||
|
|
||||||
$(BUILDDIR)/special.bin: $(SPECIAL)
|
$(BUILDDIR)/special.bin: $(SPECIAL) Data/Image/png2bin.py
|
||||||
$(PY) Data/Image/png2bin.py $(SPECIAL) $@
|
$(PY) Data/Image/png2bin.py $(SPECIAL) $@
|
||||||
|
|
||||||
$(BUILDDIR)/song.bin: $(MUSIC)
|
$(BUILDDIR)/song.bin: $(MUSIC)
|
||||||
|
|
|
@ -12,17 +12,15 @@ drawNormalFrame:
|
||||||
|
|
||||||
; Display the frame
|
; Display the frame
|
||||||
.displayFrame:
|
.displayFrame:
|
||||||
mov ah, 220 ; Set the block character to use
|
|
||||||
mov di, 1 ; Offset one byte
|
mov di, 1 ; Offset one byte
|
||||||
|
|
||||||
mov cx, frameSize
|
mov cx, frameSize
|
||||||
.draw:
|
.draw:
|
||||||
lodsb
|
lodsb
|
||||||
stosw
|
stosb
|
||||||
|
inc di
|
||||||
loop .draw
|
loop .draw
|
||||||
|
|
||||||
mov [cs:frameIndex], si
|
mov [cs:frameIndex], si
|
||||||
|
|
||||||
call drawNyanCounter
|
|
||||||
|
|
||||||
.end: ret
|
.end: ret
|
|
@ -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
|
|
20
PayloadMBR/Source/Stage2/Animation/Image/initDrawing.asm
Normal file
20
PayloadMBR/Source/Stage2/Animation/Image/initDrawing.asm
Normal 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
|
|
@ -1,20 +1,20 @@
|
||||||
nyanTimeStart: db "You Nyaned for "
|
nyanTimeString: db "You've Nyaned for 00000.0 seconds!"
|
||||||
nyanTime: db "000000.0"
|
nyanTimeStringLen: equ $-nyanTimeString
|
||||||
nyanTimeLen equ $-nyanTime
|
nyanTimeVideoStart: equ 3840
|
||||||
nyanTimeEnd: db " seconds!"
|
|
||||||
nyanTimeLenFull equ $-nyanTimeStart
|
|
||||||
|
|
||||||
nyanTimeBin dw 0
|
nyanTimeBin dw 0
|
||||||
|
|
||||||
countNyan:
|
countNyan:
|
||||||
|
setVideoMemory
|
||||||
|
|
||||||
inc word [cs:nyanTimeBin]
|
inc word [cs:nyanTimeBin]
|
||||||
|
|
||||||
mov bx, nyanTimeLen
|
mov bx, nyanTimeStringLen*2
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
dec bx
|
sub bx, 2
|
||||||
|
|
||||||
mov al, [cs:nyanTime+bx]
|
mov al, [es:nyanTimeVideoStart+bx]
|
||||||
cmp al, '0'
|
cmp al, '0'
|
||||||
jb .next
|
jb .next
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@ countNyan:
|
||||||
ja .next
|
ja .next
|
||||||
|
|
||||||
inc al
|
inc al
|
||||||
mov [cs:nyanTime+bx], al
|
mov [es:nyanTimeVideoStart+bx], al
|
||||||
|
|
||||||
cmp al, '9'+1
|
cmp al, '9'+1
|
||||||
jne .end
|
jne .end
|
||||||
|
|
||||||
mov al, '0'
|
mov al, '0'
|
||||||
mov [cs:nyanTime+bx], al
|
mov [es:nyanTimeVideoStart+bx], al
|
||||||
|
|
||||||
.next:
|
.next:
|
||||||
cmp bx, 0
|
cmp bx, 0
|
||||||
|
|
|
@ -3,12 +3,6 @@ frameIndex dw 0
|
||||||
frameSize: equ (80*50) / 2 ; Raw binary size of a frame
|
frameSize: equ (80*50) / 2 ; Raw binary size of a frame
|
||||||
lastFrame: equ special
|
lastFrame: equ special
|
||||||
|
|
||||||
%macro setVideoMemory 0
|
|
||||||
; Set the extra segment to video memory
|
|
||||||
mov cx, 0xb800
|
|
||||||
mov es, cx
|
|
||||||
%endmacro
|
|
||||||
|
|
||||||
displayFrame:
|
displayFrame:
|
||||||
setVideoMemory
|
setVideoMemory
|
||||||
|
|
||||||
|
@ -24,6 +18,13 @@ displayFrame:
|
||||||
|
|
||||||
; Reset the frame index when the intro is done
|
; Reset the frame index when the intro is done
|
||||||
mov si, frames
|
mov si, frames
|
||||||
|
|
||||||
|
; Revert the message characters
|
||||||
|
mov di, 0
|
||||||
|
mov cx, messageLength
|
||||||
|
mov ax, 0x00DC
|
||||||
|
rep stosw
|
||||||
|
|
||||||
jmp .normalFrame
|
jmp .normalFrame
|
||||||
|
|
||||||
; Intro Frame
|
; Intro Frame
|
||||||
|
@ -42,6 +43,6 @@ displayFrame:
|
||||||
|
|
||||||
.end: ret
|
.end: ret
|
||||||
|
|
||||||
|
%include "Animation/Image/initDrawing.asm"
|
||||||
%include "Animation/Image/drawIntroFrame.asm"
|
%include "Animation/Image/drawIntroFrame.asm"
|
||||||
%include "Animation/Image/drawNormalFrame.asm"
|
%include "Animation/Image/drawNormalFrame.asm"
|
||||||
%include "Animation/Image/drawNyanCounter.asm"
|
|
|
@ -18,3 +18,6 @@ mov sp, 0x2000
|
||||||
|
|
||||||
; Setup the PC speaker
|
; Setup the PC speaker
|
||||||
%include "Setup/setupSpeaker.asm"
|
%include "Setup/setupSpeaker.asm"
|
||||||
|
|
||||||
|
; Setup the screen and Nyan Counter
|
||||||
|
call initDrawing
|
|
@ -20,3 +20,9 @@
|
||||||
mov word [es:(%1+8)*4], %2 ; Interrupt Handler
|
mov word [es:(%1+8)*4], %2 ; Interrupt Handler
|
||||||
mov word [es:(%1+8)*4+2], 0 ; Segment 0x0000
|
mov word [es:(%1+8)*4+2], 0 ; Segment 0x0000
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
|
%macro setVideoMemory 0
|
||||||
|
; Set the extra segment to video memory
|
||||||
|
mov cx, 0xb800
|
||||||
|
mov es, cx
|
||||||
|
%endmacro
|
||||||
|
|
Reference in a new issue