Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 32768
- __START_PROGRAM:
- di
- push ix
- push iy
- exx
- push hl
- exx
- ld hl, 0
- add hl, sp
- ld (__CALL_BACK__), hl
- ei
- ld a, 8
- push af
- ld a, 084h
- ld de, 00060h
- ld bc, 00000h
- push bc
- push de
- push af
- ld a, 082h
- ld de, 00040h
- ld bc, 00000h
- push bc
- push de
- push af
- call _msxcolor
- call _msx1cls
- __LABEL__lp1:
- jp __LABEL__lp1
- ld hl, 0
- ld b, h
- ld c, l
- __END_PROGRAM:
- di
- ld hl, (__CALL_BACK__)
- ld sp, hl
- exx
- pop hl
- exx
- pop iy
- pop ix
- ei
- ret
- __CALL_BACK__:
- DEFW 0
- _msxcolor:
- push ix
- ld ix, 0
- add ix, sp
- push ix
- pop hl
- ld de, 5
- add hl, de
- call __PLOADF
- call __FTOU32REG
- ld a, l
- ld (62441), a
- push ix
- pop hl
- ld de, 11
- add hl, de
- call __PLOADF
- call __FTOU32REG
- ld a, l
- ld (62442), a
- ld a, (ix+17)
- ld (62443), a
- _msxcolor__leave:
- exx
- ld hl, 14
- __EXIT_FUNCTION:
- ld sp, ix
- pop ix
- pop de
- add hl, sp
- ld sp, hl
- push de
- exx
- ret
- _msx1cls:
- push ix
- ld ix, 0
- add ix, sp
- #line 1
- call 00c3h
- #line 2
- _msx1cls__leave:
- ld sp, ix
- pop ix
- ret
- #line 1 "ftou32reg.asm"
- #line 1 "neg32.asm"
- __ABS32:
- bit 7, d
- ret z
- __NEG32: ; Negates DEHL (Two's complement)
- ld a, l
- cpl
- ld l, a
- ld a, h
- cpl
- ld h, a
- ld a, e
- cpl
- ld e, a
- ld a, d
- cpl
- ld d, a
- inc l
- ret nz
- inc h
- ret nz
- inc de
- ret
- #line 2 "ftou32reg.asm"
- __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed)
- ; Input FP number in A EDCB (A exponent, EDCB mantissa)
- ; Output: DEHL 32 bit number (signed)
- PROC
- LOCAL __IS_FLOAT
- or a
- jr nz, __IS_FLOAT
- ; Here if it is a ZX ROM Integer
- ld h, c
- ld l, d
- ld a, e ; Takes sign: FF = -, 0 = +
- ld de, 0
- inc a
- jp z, __NEG32 ; Negates if negative
- ret
- __IS_FLOAT: ; Jumps here if it is a true floating point number
- ld h, e
- push hl ; Stores it for later (Contains Sign in H)
- push de
- push bc
- exx
- pop de ; Loads mantissa into C'B' E'D'
- pop bc ;
- set 7, c ; Highest mantissa bit is always 1
- exx
- ld hl, 0 ; DEHL = 0
- ld d, h
- ld e, l
- ;ld a, c ; Get exponent
- sub 128 ; Exponent -= 128
- jr z, __FTOU32REG_END ; If it was <= 128, we are done (Integers must be > 128)
- jr c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0)
- ld b, a ; Loop counter = exponent - 128
- __FTOU32REG_LOOP:
- exx ; Shift C'B' E'D' << 1, output bit stays in Carry
- sla d
- rl e
- rl b
- rl c
- exx ; Shift DEHL << 1, inserting the carry on the right
- rl l
- rl h
- rl e
- rl d
- djnz __FTOU32REG_LOOP
- __FTOU32REG_END:
- pop af ; Take the sign bit
- or a ; Sets SGN bit to 1 if negative
- jp m, __NEG32 ; Negates DEHL
- ret
- ENDP
- __FTOU8: ; Converts float in C ED LH to Unsigned byte in A
- call __FTOU32REG
- ld a, l
- ret
- #line 81 "code.bas"
- #line 1 "ploadf.asm"
- ; Parameter / Local var load
- ; A => Offset
- ; IX = Stack Frame
- ; RESULT: HL => IX + DE
- #line 1 "iloadf.asm"
- ; __FASTCALL__ routine which
- ; loads a 40 bits floating point into A ED CB
- ; stored at position pointed by POINTER HL
- ;A DE, BC <-- ((HL))
- __ILOADF:
- ld a, (hl)
- inc hl
- ld h, (hl)
- ld l, a
- ; __FASTCALL__ routine which
- ; loads a 40 bits floating point into A ED CB
- ; stored at position pointed by POINTER HL
- ;A DE, BC <-- (HL)
- __LOADF: ; Loads a 40 bits FP number from address pointed by HL
- ld a, (hl)
- inc hl
- ld e, (hl)
- inc hl
- ld d, (hl)
- inc hl
- ld c, (hl)
- inc hl
- ld b, (hl)
- ret
- #line 7 "ploadf.asm"
- __PLOADF:
- push ix
- pop hl
- add hl, de
- jp __LOADF
- #line 82 "code.bas"
- ZXBASIC_USER_DATA:
- ; Defines DATA END --> HEAP size is 0
- ZXBASIC_USER_DATA_END EQU ZXBASIC_MEM_HEAP
- ; Defines USER DATA Length in bytes
- ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement