├── tniasm.out ├── add_mouse.tcl ├── Docs ├── ATARIPL.png ├── 8x8 icons sample.png ├── tiny sprite bkp mouse arrow.txt ├── tinysprite bkp cursor resize.txt ├── msx windows tiny sprite bkp 4.txt ├── msx windows tiny sprite bkp 3.txt ├── vdp.txt ├── tileset.txt ├── tetris-rotate-draft.txt ├── icon paint tiny sprite bkp.txt ├── msx windows tiny sprite bkp.txt ├── tiny sprite notepad icon bkp.txt ├── tinysprite bkp calc icon.txt ├── icon paint tiny sprite bkp v2.txt ├── icon settings tiny sprite bkp.txt ├── msx windows tiny sprite bkp 1.txt ├── msx windows tiny sprite bkp 2.txt └── ram.txt ├── msx-windows.rom ├── openmsx.bat ├── Apps ├── Calc │ ├── Work.s │ ├── GetFocus.s │ ├── LoseFocus.s │ ├── Click.s │ ├── Close.s │ ├── Draw.s │ ├── Open.s │ ├── Icon.s │ ├── Header.s │ └── Data.s ├── Paint │ ├── Work.s │ ├── Close.s │ ├── GetFocus.s │ ├── LoseFocus.s │ ├── Open.s │ ├── Draw.s │ ├── Click.s │ ├── Data.s │ ├── Icon.s │ └── Header.s ├── Template │ ├── Draw.s │ ├── Work.s │ ├── Open.s │ ├── Close.s │ ├── GetFocus.s │ ├── LoseFocus.s │ ├── Data.s │ ├── Click.s │ ├── Icon.s │ └── Header.s ├── TicTacToe │ ├── Work.s │ ├── Close.s │ ├── GetFocus.s │ ├── LoseFocus.s │ ├── Icon.s │ ├── Open.s │ ├── Draw.s │ ├── Header.s │ ├── Data.s │ └── Click.s ├── Settings │ ├── Close.s │ ├── GetFocus.s │ ├── LoseFocus.s │ ├── Open.s │ ├── Work.s │ ├── Click.s │ ├── Header.s │ ├── Icon.s │ └── Draw.s ├── Tetra │ ├── Close.s │ ├── GetFocus.s │ ├── LoseFocus.s │ ├── Click.s │ ├── Icon.s │ ├── Header.s │ ├── Open.s │ ├── Draw.s │ └── Data.s └── Notepad │ ├── LoseFocus.s │ ├── GetFocus.s │ ├── Click.s │ ├── Data.s │ ├── Close.s │ ├── Open.s │ ├── Icon.s │ ├── Work.s │ ├── Draw.s │ └── Header.s ├── System ├── Window │ ├── CloseWindow.s │ ├── SetCustomTile.s │ ├── DrawOnWindowUsefulArea.s │ └── Window.s ├── Process │ ├── RestoreProcess.s │ ├── MaximizeProcess.s │ ├── MinimizeAllProcesses.s │ ├── SetCurrentProcess.s │ ├── MinimizeProcess.s │ ├── CloseProcess.s │ ├── Process.s │ └── LoadProcess.s ├── Init │ ├── Init.s │ ├── InitRam.s │ └── InitVdp.s ├── Mouse │ ├── DisableMouseOver.s │ ├── Mouse.s │ └── DrawMouseCursor.s ├── Constants.s ├── Time │ └── Time.s ├── Main.s ├── Interrupt.s └── Desktop │ └── Taskbar.s ├── Include ├── RomHeader.s └── MsxConstants.s ├── .vscode └── tasks.json ├── README.md ├── msx-windows_debug.tcl └── Graphics └── Sprites.s /tniasm.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /add_mouse.tcl: -------------------------------------------------------------------------------- 1 | plug joyporta mouse 2 | set grabinput on 3 | # set grabinput off 4 | -------------------------------------------------------------------------------- /Docs/ATARIPL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albs-br/msx-windows/HEAD/Docs/ATARIPL.png -------------------------------------------------------------------------------- /msx-windows.rom: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albs-br/msx-windows/HEAD/msx-windows.rom -------------------------------------------------------------------------------- /Docs/8x8 icons sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/albs-br/msx-windows/HEAD/Docs/8x8 icons sample.png -------------------------------------------------------------------------------- /openmsx.bat: -------------------------------------------------------------------------------- 1 | C:\Users\????\Downloads\openmsx-18.0-windows-vc-x64-bin\openmsx msx-windows.rom -script msx-windows_debug.tcl -script add_mouse.tcl -------------------------------------------------------------------------------- /Apps/Calc/Work.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Paint/Work.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ret 6 | -------------------------------------------------------------------------------- /Apps/Template/Draw.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ret 6 | -------------------------------------------------------------------------------- /Apps/Template/Work.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ret 6 | -------------------------------------------------------------------------------- /Apps/TicTacToe/Work.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ret 6 | -------------------------------------------------------------------------------- /Apps/Template/Open.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | 6 | ret 7 | -------------------------------------------------------------------------------- /Apps/Paint/Close.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Settings/Close.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Template/Close.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Tetra/Close.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Calc/GetFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Calc/LoseFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Paint/GetFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Paint/LoseFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Tetra/GetFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Tetra/LoseFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/TicTacToe/Close.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Notepad/LoseFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Settings/GetFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Settings/LoseFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Template/GetFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Template/LoseFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/TicTacToe/GetFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/TicTacToe/LoseFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ret -------------------------------------------------------------------------------- /Apps/Template/Data.s: -------------------------------------------------------------------------------- 1 | 2 | .TETRA_TILES: 3 | 4 | ; ------------------------- 5 | 6 | TETRA_VARS: 7 | ; .PLAYFIELD: equ 0 ; 3 * 3 = 9 bytes 8 | ; .CURRENT_PLAYER: equ 9 9 | -------------------------------------------------------------------------------- /System/Window/CloseWindow.s: -------------------------------------------------------------------------------- 1 | ; Input: 2 | ; HL = addr of process header 3 | _CLOSE_WINDOW: 4 | 5 | ; call _RESTORE_TILES_BEHIND_WINDOW 6 | 7 | 8 | 9 | 10 | 11 | 12 | ret -------------------------------------------------------------------------------- /Apps/Notepad/GetFocus.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; clear keyboard buffer 6 | call BIOS_KILBUF 7 | 8 | ret -------------------------------------------------------------------------------- /Apps/Template/Click.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | ; HL = click position in tiles relative to window useful area top left, L = column, H = line 5 | 6 | 7 | ret 8 | -------------------------------------------------------------------------------- /Apps/Tetra/Click.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | ; HL = click position in tiles relative to window useful area top left, L = column, H = line 5 | 6 | 7 | ret 8 | -------------------------------------------------------------------------------- /Apps/Calc/Click.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | ; HL = click position in tiles relative to window useful area top left, L = column, H = line 5 | 6 | ; code here 7 | 8 | ret -------------------------------------------------------------------------------- /Apps/Notepad/Click.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | ; HL = click position in tiles relative to window useful area top left, L = column, H = line 5 | 6 | ; code here 7 | 8 | ret -------------------------------------------------------------------------------- /Apps/Notepad/Data.s: -------------------------------------------------------------------------------- 1 | 2 | NOTEPAD_VARS: 3 | .CURSOR_POSITION: equ 0 4 | ; .KEYPRESSED: equ 1 5 | .TEXT_START: equ 1 6 | 7 | TEXT_END_OF_FILE: equ 255 8 | 9 | ; TEST_NOTEPAD_OPEN_EVENT_STRING: db 'N OPEN', 0 10 | 11 | ; TEST_NOTEPAD_DRAW_EVENT_STRING: db 'N DRAW', 0 12 | 13 | ; TEST_NOTEPAD_WORK_EVENT_STRING: db 'N WORK', 0 -------------------------------------------------------------------------------- /Apps/Notepad/Close.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | ; ; debug 8 | ; ld b, 10 9 | ; .test: 10 | ; push bc 11 | ; call BIOS_BEEP 12 | ; pop bc 13 | ; djnz .test 14 | 15 | ret -------------------------------------------------------------------------------- /Apps/Calc/Close.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; code here 6 | 7 | 8 | ; ; debug 9 | ; ld b, 20 10 | ; .test: 11 | ; push bc 12 | ; call BIOS_BEEP 13 | ; pop bc 14 | ; djnz .test 15 | 16 | 17 | ret -------------------------------------------------------------------------------- /System/Process/RestoreProcess.s: -------------------------------------------------------------------------------- 1 | ; Input: 2 | ; HL = addr of process header 3 | _RESTORE_PROCESS: 4 | 5 | ; IX = HL 6 | push hl 7 | pop ix 8 | 9 | ; set status = RESTORED 10 | ld a, WINDOW_STATE.RESTORED 11 | ld (ix + PROCESS_STRUCT_IX.windowState), a 12 | 13 | call _SET_CURRENT_PROCESS 14 | 15 | call _DISABLE_MOUSE_OVER 16 | 17 | ret -------------------------------------------------------------------------------- /Docs/tiny sprite bkp mouse arrow.txt: -------------------------------------------------------------------------------- 1 | !type 2 | msx1 3 | #Slot 0 4 | 1............... 5 | 11.............. 6 | 1F1............. 7 | 1FF1............ 8 | 1FFF1........... 9 | 1FFFF1.......... 10 | 1FFFFF1......... 11 | 1FFFFFF1........ 12 | 1FFFFFFF1....... 13 | 1FFFFFFFF1...... 14 | 1FFFFF1111...... 15 | 1FF1FF1......... 16 | 1F1.1FF1........ 17 | 11..1FF1........ 18 | .....11......... 19 | ................ 20 | -------------------------------------------------------------------------------- /Apps/Paint/Open.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; ; get RAM variables area of this process 6 | ; ld l, (ix + PROCESS_STRUCT_IX.ramStartAddr) 7 | ; ld h, (ix + PROCESS_STRUCT_IX.ramStartAddr + 1) 8 | 9 | ; push hl ; IY = HL 10 | ; pop iy 11 | 12 | ld a, TILE_COLOR_1 ; black color 13 | ld (iy + PAINT_VARS.CURRENT_COLOR), a 14 | 15 | ret 16 | -------------------------------------------------------------------------------- /Include/RomHeader.s: -------------------------------------------------------------------------------- 1 | ; ROM header (Put 0000h as address when unused) 2 | db "AB" ; ID for auto-executable Rom at MSX start 3 | dw Execute ; Main program execution address. 4 | dw 0 ; Execution address of a program whose purpose is to add 5 | ; instructions to the MSX-Basic using the CALL statement. 6 | dw 0 ; Execution address of a program used to control a device 7 | ; built into the cartridge. 8 | dw 0 ; Basic program pointer contained in ROM. 9 | dw 0, 0, 0 ; Reserved 10 | 11 | -------------------------------------------------------------------------------- /System/Process/MaximizeProcess.s: -------------------------------------------------------------------------------- 1 | ; Input: 2 | ; HL = addr of process header 3 | _MAXIMIZE_PROCESS: 4 | 5 | ; IX = HL 6 | push hl 7 | pop ix 8 | 9 | ; TODO: 10 | ; if (windowState == MAXIMIZED) ret 11 | 12 | ; set status = MAXIMIZED 13 | ld a, WINDOW_STATE.MAXIMIZED 14 | ld (ix + PROCESS_STRUCT_IX.windowState), a 15 | 16 | call _SET_CURRENT_PROCESS 17 | 18 | ; call _UPDATE_SCREEN 19 | 20 | call _DISABLE_MOUSE_OVER 21 | 22 | ; call _DRAW_TASKBAR 23 | 24 | ret -------------------------------------------------------------------------------- /System/Init/Init.s: -------------------------------------------------------------------------------- 1 | INCLUDE "System/Init/InitVdp.s" 2 | INCLUDE "System/Init/InitRam.s" 3 | 4 | 5 | 6 | 7 | _INIT: 8 | 9 | ; disable keyboard click sound 10 | xor a 11 | ld (BIOS_CLIKSW), a 12 | 13 | call _INIT_VDP 14 | 15 | call _INIT_RAM 16 | 17 | call _INIT_SYSTEM_TIME 18 | 19 | call _INIT_INTERRUPT 20 | 21 | call _INIT_DESKTOP 22 | 23 | 24 | 25 | ; ---------------------------------- 26 | 27 | 28 | call _DRAW_DESKTOP 29 | call _DRAW_TASKBAR 30 | 31 | ret 32 | 33 | 34 | -------------------------------------------------------------------------------- /System/Process/MinimizeAllProcesses.s: -------------------------------------------------------------------------------- 1 | _MINIMIZE_ALL_PROCESSES: 2 | 3 | ; loop through all process minimizing them 4 | ld hl, OS.processes 5 | ld de, Process_struct.size 6 | ld b, MAX_PROCESS_ID + 1 7 | .loop_1: 8 | ld a, (hl) 9 | cp 0xff ; if process slot empty go to the next 10 | jp z, .next_1 11 | 12 | push hl, de, bc 13 | ld c, a 14 | call _GET_PROCESS_BY_ID 15 | 16 | call _MINIMIZE_PROCESS 17 | pop bc, de, hl 18 | 19 | .next_1: 20 | add hl, de 21 | djnz .loop_1 22 | 23 | ret -------------------------------------------------------------------------------- /Apps/Settings/Open.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; ; get RAM variables area of this process 6 | ; ld l, (ix + PROCESS_STRUCT_IX.ramStartAddr) 7 | ; ld h, (ix + PROCESS_STRUCT_IX.ramStartAddr + 1) 8 | 9 | ; push hl ; IY = HL 10 | ; pop iy 11 | 12 | ; init current tab var 13 | ld a, SETTINGS_TABS_VALUES.TAB_VIDEO 14 | ld (iy + SETTINGS_VARS.TAB_SELECTED), a 15 | 16 | 17 | xor a 18 | ld (iy + SETTINGS_VARS.CHECKBOX_SHOW_TICKS_VALUE), a 19 | 20 | ret 21 | -------------------------------------------------------------------------------- /System/Mouse/DisableMouseOver.s: -------------------------------------------------------------------------------- 1 | ; Input: nothing 2 | ; Output: nothing 3 | _DISABLE_MOUSE_OVER: 4 | ; ---------- disable mouse over 5 | ; reset flag mouseOver_Activated 6 | xor a 7 | ld (OS.mouseOver_Activated), a 8 | 9 | ; reset mouseOver_screenMappingValue 10 | ld (OS.mouseOver_screenMappingValue), a 11 | 12 | ; get mouse over NAMTBL addr previously saved 13 | ld hl, (OS.mouseOver_NAMTBL_addr) 14 | call BIOS_SETWRT 15 | 16 | ld a, TILE_EMPTY 17 | out (PORT_0), a 18 | 19 | ld a, SCREEN_MAPPING_DESKTOP ; 255 20 | ld (OS.currentTileMouseOver), a 21 | 22 | ret -------------------------------------------------------------------------------- /Apps/Calc/Draw.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | 6 | call GET_USEFUL_WINDOW_BASE_NAMTBL 7 | 8 | ; if (windowState == MAXIMIZED) HL++ 9 | ld a, (ix + PROCESS_STRUCT_IX.windowState) 10 | cp WINDOW_STATE.MAXIMIZED 11 | jp nz, .skip_1 12 | inc hl 13 | .skip_1: 14 | 15 | ex de, hl 16 | 17 | ; draw calc display and keypad 18 | ld hl, Calc_Data.CALC_DISPLAY_TILES ; RAM address (source) 19 | ld b, 12 ; size of line 20 | ld c, 2 + 12 ; number of lines 21 | call DRAW_ON_WINDOW_USEFUL_AREA 22 | 23 | ret 24 | -------------------------------------------------------------------------------- /Apps/Calc/Open.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; ; get base NAMTBL of the window 6 | ; ; push hl ; ix = hl 7 | ; ; pop ix 8 | ; ld l, (ix + PROCESS_STRUCT_IX.x) ; process.x 9 | ; ld h, (ix + PROCESS_STRUCT_IX.y) ; process.y 10 | ; call _CONVERT_COL_LINE_TO_LINEAR 11 | 12 | ; ld bc, NAMTBL + (32 * 2) + 1; two lines below and one column right 13 | ; add hl, bc 14 | 15 | ; call _GET_WINDOW_BASE_NAMTBL 16 | 17 | ; ; debug 18 | ; ; write a test char 19 | ; call BIOS_SETWRT 20 | ; ld a, TILE_FONT_UPPERCASE_A + 1 ; 'B' 21 | ; out (PORT_0), a 22 | 23 | ret -------------------------------------------------------------------------------- /Apps/Paint/Draw.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | call GET_USEFUL_WINDOW_BASE_NAMTBL 6 | 7 | ; if (windowState == MAXIMIZED) HL++ 8 | ld a, (ix + PROCESS_STRUCT_IX.windowState) 9 | cp WINDOW_STATE.MAXIMIZED 10 | jp nz, .skip_1 11 | inc hl 12 | .skip_1: 13 | 14 | ex de, hl 15 | 16 | ; draw paint left toolbar 17 | push de 18 | ld hl, Paint_Data.PAINT_TOOLBAR ; RAM address (source) 19 | ld b, 3 ; size of line 20 | ld c, 1 + 8 + 4 ; number of lines 21 | call DRAW_ON_WINDOW_USEFUL_AREA 22 | pop hl 23 | 24 | ret 25 | -------------------------------------------------------------------------------- /Apps/Notepad/Open.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; ; get RAM variables area of this process 6 | ; ld l, (ix + PROCESS_STRUCT_IX.ramStartAddr) 7 | ; ld h, (ix + PROCESS_STRUCT_IX.ramStartAddr + 1) 8 | 9 | ; push hl ; IY = HL 10 | ; pop iy 11 | 12 | ; cursor = 0 13 | xor a 14 | ld (iy + NOTEPAD_VARS.CURSOR_POSITION), a 15 | 16 | ; set empty text 17 | ld a, TEXT_END_OF_FILE 18 | ld (iy + NOTEPAD_VARS.TEXT_START), a 19 | 20 | ; clear keyboard buffer 21 | call BIOS_KILBUF 22 | 23 | ; xor a 24 | ; ld (iy + NOTEPAD_VARS.KEYPRESSED), a 25 | 26 | 27 | ret 28 | -------------------------------------------------------------------------------- /Docs/tinysprite bkp cursor resize.txt: -------------------------------------------------------------------------------- 1 | !type 2 | msx1 3 | #Slot 0 4 | 1111111......... 5 | 1FFFF1.......... 6 | 1FFF1........... 7 | 1FFFF1.......... 8 | 1F1FFF1......... 9 | 11.1FFF1........ 10 | 1...1FFF1....... 11 | .....1FFF1...... 12 | ......1FFF1..... 13 | .......1FFF1...1 14 | ........1FFF1.11 15 | .........1FFF1F1 16 | ..........1FFFF1 17 | ...........1FFF1 18 | ..........1FFFF1 19 | .........1111111 20 | #Slot 1 21 | ................ 22 | ................ 23 | ................ 24 | ................ 25 | ................ 26 | ................ 27 | ................ 28 | ................ 29 | ................ 30 | ...........1...1 31 | ............1.11 32 | .........1...1.1 33 | ..........1....1 34 | ...........1...1 35 | ..........1....1 36 | .........1111111 -------------------------------------------------------------------------------- /Docs/msx windows tiny sprite bkp 4.txt: -------------------------------------------------------------------------------- 1 | !type 2 | msx1 3 | #Slot 0 4 | ................ 5 | ................ 6 | ................ 7 | ................ 8 | ................ 9 | ................ 10 | 1111111111111111 11 | 1......11......1 12 | .1111111.1111111 13 | .1111111.1.....1 14 | .1111111.1.....1 15 | .1111111.1.111.1 16 | .1.....1.1.111.1 17 | .1.....1.1.....1 18 | 1111111111111111 19 | 1111111111111111 20 | #Slot 1 21 | ................ 22 | ................ 23 | ................ 24 | ................ 25 | ................ 26 | ................ 27 | 111111111111.... 28 | 1......11111.... 29 | .11111111111.... 30 | .1.111.11111111. 31 | .11.1.111111111. 32 | .111.1111111111. 33 | .11.1.111111111. 34 | .1.111.11111111. 35 | 111111111111111. 36 | 111111111111111. -------------------------------------------------------------------------------- /Apps/Paint/Click.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | ; HL = click position in tiles relative to window useful area top left, L = column, H = line 5 | 6 | push hl 7 | call GET_MOUSE_POSITION_IN_TILES 8 | 9 | ; TODO 10 | ; check if user clicked left toolbar 11 | 12 | call _CONVERT_COL_LINE_TO_LINEAR 13 | 14 | ld bc, NAMTBL 15 | add hl, bc 16 | 17 | 18 | 19 | call BIOS_SETWRT 20 | ld a, (iy + PAINT_VARS.CURRENT_COLOR) 21 | ; ld a, TILE_EMPTY_BLACK 22 | out (PORT_0), a 23 | pop hl 24 | 25 | ; TODO: check if user clicked on toolbar buttons 26 | ; ld a, h 27 | ; cp 2 28 | 29 | ret -------------------------------------------------------------------------------- /Apps/Settings/Work.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; ; get RAM variables area of this process 6 | ; ld l, (ix + PROCESS_STRUCT_IX.ramStartAddr) 7 | ; ld h, (ix + PROCESS_STRUCT_IX.ramStartAddr + 1) 8 | 9 | ; push hl ; IY = HL 10 | ; pop iy 11 | 12 | 13 | 14 | ; if(currentTab == TIME) call "Draw" event 15 | ld a, (iy + SETTINGS_VARS.TAB_SELECTED) 16 | cp SETTINGS_TABS_VALUES.TAB_TIME 17 | ret nz 18 | 19 | ; ; call "Draw" event of this process 20 | ; ld e, (ix + PROCESS_STRUCT_IX.drawAddr) ; process.Draw addr (low) 21 | ; ld d, (ix + PROCESS_STRUCT_IX.drawAddr + 1) ; process.Draw addr (high) 22 | ; call JP_DE 23 | 24 | call Settings_Draw.DrawClock 25 | 26 | ret 27 | -------------------------------------------------------------------------------- /System/Constants.s: -------------------------------------------------------------------------------- 1 | ; Constants 2 | 3 | ; constants (refer to Ram.s (OS.screenMapping) for explanation) 4 | SCREEN_MAPPING_DESKTOP: equ 255 5 | SCREEN_MAPPING_TASKBAR: equ 254 6 | ; low nibble = process id 7 | SCREEN_MAPPING_WINDOWS: equ 0000 0000 b 8 | SCREEN_MAPPING_WINDOWS_TITLE_BAR: equ 0001 0000 b 9 | SCREEN_MAPPING_WINDOWS_MINIMIZE_BUTTON: equ 0010 0000 b 10 | SCREEN_MAPPING_WINDOWS_MAXIMIZE_RESTORE_BUTTON: equ 0011 0000 b 11 | SCREEN_MAPPING_WINDOWS_CLOSE_BUTTON: equ 0100 0000 b 12 | SCREEN_MAPPING_WINDOWS_RESIZE_CORNER: equ 0101 0000 b 13 | 14 | 15 | WINDOW_STATE: 16 | .MINIMIZED: equ 1 17 | .RESTORED: equ 2 18 | .MAXIMIZED: equ 3 19 | 20 | 21 | MOUSE_ON_JOYPORT_1: equ 0x1310 22 | MOUSE_ON_JOYPORT_2: equ 0x6C20 23 | 24 | MOUSE_PORT: equ MOUSE_ON_JOYPORT_1 25 | 26 | MOUSE_DOUBLE_CLICK_INTERVAL: equ 30 ; number of frames between clicks to be considered a double click -------------------------------------------------------------------------------- /Docs/msx windows tiny sprite bkp 3.txt: -------------------------------------------------------------------------------- 1 | !type 2 | msx1 3 | #Slot 0 4 | ................ 5 | ................ 6 | ................ 7 | ................ 8 | ................ 9 | ................ 10 | 1111111111111111 11 | 1111111111111111 12 | 1111111111111111 13 | 1111111111.....1 14 | 1111111111.....1 15 | 1111111111.111.1 16 | 11.....111.111.1 17 | 11.....111.....1 18 | 1111111111111111 19 | 1111111111111111 20 | #Slot 1 21 | ................ 22 | ................ 23 | ................ 24 | ................ 25 | ................ 26 | ................ 27 | 111111111111.... 28 | 111111111111.... 29 | 111111111111.... 30 | 11.111.11111111. 31 | 111.1.111111111. 32 | 1111.1111111111. 33 | 111.1.111111111. 34 | 11.111.11111111. 35 | 111111111111111. 36 | 111111111111111. 37 | #Slot 3 38 | ................ 39 | ............1... 40 | ....1........... 41 | ...111.......... 42 | ..11111......... 43 | ............1... 44 | ................ 45 | ................ 46 | ................ 47 | .........1111111 48 | .........1111111 49 | ..11111..1111111 50 | ...111...1111111 51 | ....1....1111111 52 | .........1111111 53 | .........1111111 -------------------------------------------------------------------------------- /Docs/vdp.txt: -------------------------------------------------------------------------------- 1 | ; info: 9918 needs 29 cycles apart from each OUT 2 | 3 | ; There are 262 lines on NTSC and 313 lines on PAL. 4 | ; Each line takes exactly 228 CPU cycles if the VDP and CPU are clocked by the same clock crystal. 5 | ; Consequently, a frame takes 262 × 228 = 59736 CPU cycles on NTSC and 313 × 228 = 71364 CPU cycles on PAL. 6 | ; The precise display frequency is therefore 59.92 Hz on NTSC and 50.16 Hz on PAL. 7 | 8 | ; You can find the specification of this in appendix section 7 of the V9938 application manual and in section 3.6 of the TMS9918 application manual. 9 | 10 | ; Finally, during vertical blanking or when the screen is disabled, there is no speed limit. 11 | ; This applies to both the TMS9918 and the V9938. When you intend to exploit this fact, please 12 | ; be aware that at 60Hz, the vertical blanking period is shorter than at 50Hz. Test your code on both European and Japanese machines. 13 | 14 | ; outi = 18 cycles on MSX 15 | ; 32 x 22 = 704 16 | ; 704 * 18 = 12672 cycles 17 | 18 | ; VBLANK = 262 - 192 = 70 lines 19 | ; 70 * 228 cycles = 15960 cycles 20 | -------------------------------------------------------------------------------- /Docs/tileset.txt: -------------------------------------------------------------------------------- 1 | 52 26 alpha x 2 2 | 10 numbers 3 | 10 others () 4 | 5 | based on standard msx charset: 6 | 96 alphanumeric + specials 7 | 36 alphanumeric reversed (only lowercase), for title bar (*) 8 | 9 | 96 + 36 = 132 (124 remainder) 10 | 11 | tiles reserved for processes: 12 per process 12 | 12 * 4 = 48 13 | 14 | 132 + 48 = 180 (76 remainder) 15 | 16 | ; desktop (tile patterns different for each third): 17 | 18 | 24x24 icon = 9 tiles 19 | 9 * 3 = 27 <--- this will be the choice 20 | 21 | 16x16 icon = 4 tiles 22 | 4 * 3 = 12 23 | 24 | 25 | 76 - 27 = 49 26 | 27 | ------------ 28 | 29 | 13 for window borders 30 | 3 for title bar buttons 31 | 32 | 9 for line borders (can be used to make buttons, tabs, etc) 33 | 6 for scroll bar (vert/horiz) 34 | 1 for system taskbar 35 | 36 | 37 | ? for app menubar 38 | 39 | total = 32 40 | 41 | 42 | 43 | 44 | 45 | 46 | --------- 47 | 48 | minesweeper: 49 | 50 | 1-9 51 | 52 | (untouched cell 53 | empty cell) 54 | or 55 | (bomb 56 | bomb red) 57 | 58 | total: 11 59 | 60 | ------- 61 | paint: 62 | 16 tiles for 2x2 px per tile 63 | (all empty and all filled already exists, so is needed 14 tiles) 64 | 65 | -------- 66 | 67 | tiles reserved for apps: 68 | 12 per app 69 | 4 apps = 48 -------------------------------------------------------------------------------- /Docs/tetris-rotate-draft.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | .currentPiece: rb 4*4 5 | 6 | .tempPiece: rb 4*4 7 | 8 | 9 | ; Inputs: 10 | ; HL: source addr (line of 4 blocks) 11 | ; DE: destiny addr (column of 4 blocks) 12 | RotatePiece: 13 | 14 | ld b, 4 15 | .loop: 16 | ld a, (hl) 17 | ld (de), a 18 | 19 | ; de = de + 4 20 | inc de 21 | inc de 22 | inc de 23 | inc de 24 | 25 | inc hl 26 | 27 | djnz .loop 28 | 29 | ret 30 | 31 | 32 | ; --- definitive code: 33 | 34 | ; Inputs: 35 | ; HL: source addr (matrix of 4x4 blocks) 36 | ; DE: destiny addr (matrix of 4x4 blocks) 37 | .RotatePiece_Right: 38 | 39 | push ix, iy 40 | 41 | push hl ; IX = HL 42 | pop ix 43 | push de ; IY = DE 44 | pop iy 45 | 46 | ; line 0 to column 3 47 | inc iy ; IY += 3 48 | inc iy 49 | inc iy 50 | call .RotatePiece_LineToCol 51 | 52 | ; line 1 to column 2 53 | inc ix ; IX++ 54 | dec iy ; IY-- 55 | call .RotatePiece_LineToCol 56 | 57 | ; line 2 to column 1 58 | inc ix ; IX++ 59 | dec iy ; IY-- 60 | call .RotatePiece_LineToCol 61 | 62 | ; line 3 to column 0 63 | inc ix ; IX++ 64 | dec iy ; IY-- 65 | call .RotatePiece_LineToCol 66 | 67 | pop iy, ix 68 | 69 | ret 70 | 71 | .RotatePiece_LineToCol: 72 | ld a, (ix + 0) 73 | ld (iy + 0), a 74 | 75 | ld a, (ix + 1) 76 | ld (iy + 4), a 77 | 78 | ld a, (ix + 2) 79 | ld (iy + 8), a 80 | 81 | ld a, (ix + 3) 82 | ld (iy + 12), a 83 | 84 | ret -------------------------------------------------------------------------------- /Docs/icon paint tiny sprite bkp.txt: -------------------------------------------------------------------------------- 1 | !type 2 | msx1 3 | #Slot 0 4 | ................ 5 | ........11111... 6 | ......11....111. 7 | .....1...11..111 8 | ....1...1111..11 9 | ....1...1111..11 10 | ....1....11....1 11 | ...1..11.......1 12 | ...1.1111...1111 13 | ...1..111..1..11 14 | ...1.......1.111 15 | ...1..11....11.1 16 | ...1..111....11. 17 | ...1..111....... 18 | ....1..11...111. 19 | ....1......1111. 20 | #Slot 1 21 | ................ 22 | ................ 23 | ..1............. 24 | ..11............ 25 | ..11............ 26 | .1.1............ 27 | 1.1............. 28 | 11.............. 29 | 111............. 30 | ..11............ 31 | ...11........... 32 | ...11........... 33 | ...11........... 34 | ...11........... 35 | ...11........... 36 | ..111........... 37 | #Slot 2 38 | .....11......... 39 | ......1111111111 40 | .....11.11111111 41 | ....11.......... 42 | ................ 43 | ................ 44 | ................ 45 | ................ 46 | ................ 47 | ................ 48 | ................ 49 | ................ 50 | ................ 51 | ................ 52 | ................ 53 | ................ 54 | #Slot 3 55 | .111....44444444 56 | 111.....44444444 57 | 11......44444444 58 | ........44444444 59 | ........44444444 60 | ........44444444 61 | ........44444444 62 | ........44444444 63 | 4444444444444444 64 | 4444444444444444 65 | 4444444444444444 66 | 4444444444444444 67 | 4444444444444444 68 | 4444444444444444 69 | 4444444444444444 70 | 4444444444444444 -------------------------------------------------------------------------------- /Docs/msx windows tiny sprite bkp.txt: -------------------------------------------------------------------------------- 1 | !type 2 | msx1 3 | #Slot 0 4 | ................ 5 | ..11111111111111 6 | .111111111111111 7 | .111111111111111 8 | .111111111....11 9 | .11111111..11..1 10 | .11111111..11..1 11 | .11111111..11..1 12 | .11111111..11..1 13 | .11111111..11..1 14 | .111111111....11 15 | .111111111111111 16 | .111111111111111 17 | .111111111111111 18 | .111111111111111 19 | .1.............. 20 | #Slot 1 21 | ................ 22 | 11111111111..... 23 | 1.........11.... 24 | .111111111.1.... 25 | .1..111..1.111.. 26 | .11..1..11.1111. 27 | .111...111.1111. 28 | .1111.1111.1111. 29 | .111...111.1111. 30 | .11..1..11.1111. 31 | .1..111..1.1111. 32 | .111111111.1111. 33 | 1.........11111. 34 | 111111111111111. 35 | 111111111111111. 36 | ...........1111. 37 | #Slot 2 38 | .1.............. 39 | .1.............. 40 | .1.............. 41 | .1.............. 42 | .1.............. 43 | .1.............. 44 | .1.............. 45 | .1.............. 46 | .1.............. 47 | .1.............. 48 | .1.............. 49 | .111111111111111 50 | ....111111111111 51 | ....111111111111 52 | ....111111111111 53 | ................ 54 | #Slot 3 55 | ...........1111. 56 | ...........1111. 57 | ...........1111. 58 | ...........1111. 59 | ...........1111. 60 | ..........11111. 61 | .........111111. 62 | ........11.1111. 63 | .......11.11111. 64 | ......11.111111. 65 | .....11.11.1111. 66 | 111111111111111. 67 | 111111111111111. 68 | 111111111111111. 69 | 111111111111111. 70 | ................ -------------------------------------------------------------------------------- /Docs/tiny sprite notepad icon bkp.txt: -------------------------------------------------------------------------------- 1 | !type 2 | msx1 3 | #Slot 0 4 | .........11.11.1 5 | .......11.11.11. 6 | ......1..1..1..1 7 | ......1......... 8 | .....1.......... 9 | .....1.......... 10 | ....1...11111111 11 | ....1........... 12 | ...1...11111111. 13 | ...1............ 14 | ..1............. 15 | ..1............. 16 | .1.............. 17 | .1.............1 18 | 1..............1 19 | 1.............1. 20 | #Slot 1 21 | 1.11............ 22 | 11.111.......... 23 | ..1..11......... 24 | ....1.11........ 25 | ....1.11........ 26 | ...1..11........ 27 | ...1.111........ 28 | ..1...11........ 29 | ..1..111........ 30 | .1.1..11........ 31 | .1...111........ 32 | 1.11..11........ 33 | 1....111........ 34 | .111..11........ 35 | .....111........ 36 | 1111..11........ 37 | #Slot 2 38 | 1.............1. 39 | .1111111111111.1 40 | ........1....... 41 | ........1.111111 42 | ........1....... 43 | ........1.1.1.1. 44 | .........1111111 45 | ..........111111 46 | ................ 47 | ................ 48 | ................ 49 | ................ 50 | ................ 51 | ................ 52 | ................ 53 | ................ 54 | #Slot 3 55 | .....111........ 56 | 1111..11........ 57 | .....111........ 58 | 1111..11........ 59 | .....111........ 60 | 1.1.1111........ 61 | 1111111......... 62 | 111111.......... 63 | ................ 64 | ................ 65 | ................ 66 | ................ 67 | ................ 68 | ................ 69 | ................ 70 | ................ -------------------------------------------------------------------------------- /Docs/tinysprite bkp calc icon.txt: -------------------------------------------------------------------------------- 1 | !type 2 | msx1 3 | #Slot 0 4 | ................ 5 | ................ 6 | ..11111111111111 7 | .1.............. 8 | .1.1111111111... 9 | .1.1........1... 10 | .1.1111111111... 11 | .1.............. 12 | .1..1..1..1..1.. 13 | .1.11.11.11.11.1 14 | .1.............. 15 | .1..1..1..1..1.. 16 | .1.11.11.11.11.1 17 | .1.............. 18 | .1..1..1..1..1.. 19 | .1.11.11.11.11.1 20 | #Slot 1 21 | ................ 22 | ................ 23 | 11111........... 24 | .....1.......... 25 | .....11......... 26 | .....11......... 27 | .....11......... 28 | .....11......... 29 | 1..1.11......... 30 | 1.11.11......... 31 | .....11......... 32 | 1..1.11......... 33 | 1.11.11......... 34 | .....11......... 35 | ...1.11......... 36 | 1111.11......... 37 | #Slot 2 38 | .1.............. 39 | ..11111111111111 40 | ...1111111111111 41 | ................ 42 | ................ 43 | ................ 44 | ................ 45 | ................ 46 | ................ 47 | ................ 48 | ................ 49 | ................ 50 | ................ 51 | ................ 52 | ................ 53 | ................ 54 | #Slot 3 55 | .....11......... 56 | 1111111......... 57 | 111111.......... 58 | ................ 59 | ................ 60 | ................ 61 | ................ 62 | ................ 63 | ................ 64 | ................ 65 | ................ 66 | ................ 67 | ................ 68 | ................ 69 | ................ 70 | ................ -------------------------------------------------------------------------------- /Docs/icon paint tiny sprite bkp v2.txt: -------------------------------------------------------------------------------- 1 | !type 2 | msx1 3 | #Slot 0 4 | ................ 5 | ......111111.... 6 | ....11......11.. 7 | ...1...111...11. 8 | ..1...11111...11 9 | ..1...11111....1 10 | ..1....111.....1 11 | .1.............. 12 | .1..111.......11 13 | .1..1111.....1.. 14 | .1.111111...1..1 15 | .1.11111....1.1. 16 | .1...........1.1 17 | .1.....11.....11 18 | ..1...111....... 19 | ..1...1111....11 20 | #Slot 1 21 | ........44444444 22 | .....1..44444444 23 | .....11.44444444 24 | .....11.44444444 25 | ....1.1.44444444 26 | ...1.11.44444444 27 | 1..1111.44444444 28 | 1.1.11..44444444 29 | 11.1....44444444 30 | 111.....44444444 31 | .111....44444444 32 | 11.11...44444444 33 | .1..11..44444444 34 | 1...11..44444444 35 | ....11..44444444 36 | ....11..44444444 37 | #Slot 2 38 | ...1..1111..1111 39 | ...1....11..1111 40 | ....1........111 41 | .....11......... 42 | ......1111111111 43 | .....11.11111111 44 | ....11.......... 45 | ................ 46 | 4444444444444444 47 | 4444444444444444 48 | 4444444444444444 49 | 4444444444444444 50 | 4444444444444444 51 | 4444444444444444 52 | 4444444444444444 53 | 4444444444444444 54 | #Slot 3 55 | 1..111..44444444 56 | ..111...44444444 57 | .111....44444444 58 | 111.....44444444 59 | 11......44444444 60 | 1.......44444444 61 | ........44444444 62 | ........44444444 63 | 4444444444444444 64 | 4444444444444444 65 | 4444444444444444 66 | 4444444444444444 67 | 4444444444444444 68 | 4444444444444444 69 | 4444444444444444 70 | 4444444444444444 -------------------------------------------------------------------------------- /Docs/icon settings tiny sprite bkp.txt: -------------------------------------------------------------------------------- 1 | !type 2 | msx1 3 | #Slot 0 4 | ................ 5 | ................ 6 | ..........1111.. 7 | .........1....1. 8 | .....11..111111. 9 | ....1..111..1.11 10 | ....1....1...11. 11 | .....1...1..1.1. 12 | .....1..11...111 13 | ..111..1.1..1.1. 14 | ..1.....11...111 15 | ..1.1.1..111111. 16 | ..11.1.......... 17 | ...11...111..111 18 | ....1..1..1..1.. 19 | ....1.1...1..1.. 20 | #Slot 1 21 | ................ 22 | ................ 23 | ................ 24 | ................ 25 | .11............. 26 | 1..1............ 27 | ...1............ 28 | ..1............. 29 | ..1............. 30 | 1..11........... 31 | .....1.......... 32 | .1.1.1.......... 33 | ..1.11.......... 34 | 1..11........... 35 | .1.1............ 36 | .111............ 37 | #Slot 2 38 | ....1.1.111..111 39 | ....1.11..1..1.. 40 | ....111...1..1.. 41 | ..........1111.. 42 | ................ 43 | ................ 44 | ................ 45 | ................ 46 | ................ 47 | ................ 48 | ................ 49 | ................ 50 | ................ 51 | ................ 52 | ................ 53 | ................ 54 | #Slot 3 55 | .111............ 56 | 1111............ 57 | .11............. 58 | ................ 59 | ................ 60 | ................ 61 | ................ 62 | ................ 63 | ................ 64 | ................ 65 | ................ 66 | ................ 67 | ................ 68 | ................ 69 | ................ 70 | ................ -------------------------------------------------------------------------------- /Docs/msx windows tiny sprite bkp 1.txt: -------------------------------------------------------------------------------- 1 | !type 2 | msx1 3 | #Slot 0 4 | ................ 5 | ..11111111111111 6 | .111111111111111 7 | .111111111111111 8 | .111111111....11 9 | .11111111..11..1 10 | .11111111..11..1 11 | .11111111..11..1 12 | .11111111..11..1 13 | .11111111..11..1 14 | .111111111....11 15 | .111111111111111 16 | .111111111111111 17 | .111111111111111 18 | .111111111111111 19 | .1EEEEEEEEEEEEEE 20 | #Slot 1 21 | ................ 22 | 1111111111111111 23 | 1111111111111111 24 | 1111111111111111 25 | 1111111111111111 26 | 1111111111111111 27 | 1111111111111111 28 | 1111111111111111 29 | 1111111111111111 30 | 1111111111111111 31 | 1111111111111111 32 | 1111111111111111 33 | 1111111111111111 34 | 1111111111111111 35 | 1111111111111111 36 | EEEEEEEEEEEEEEEE 37 | #Slot 2 38 | .1EEEEEEE111111E 39 | .1EEEEEEEE11EE1E 40 | .1EEEEEEEE11EEEE 41 | .1EEEEEEEE1111EE 42 | .1EEEEEEEE11EEEE 43 | .1EEEEEEEE11EEEE 44 | .1EEEEEEE1111EEE 45 | .1EEEEEEEEEEEEEE 46 | .1.............. 47 | .1.............. 48 | .1.............. 49 | .1.............. 50 | .1.............. 51 | .1.............. 52 | .1.............. 53 | .1.............. 54 | #Slot 3 55 | EEEEEEEEEEEEEEEE 56 | EEEEEEEEEEEEEEEE 57 | EEEEEEEEEEEEEEEE 58 | EEEEEEEEEEEEEEEE 59 | EEEEEEEEEEEEEEEE 60 | EEEEEEEEEEEEEEEE 61 | EEEEEEEEEEEEEEEE 62 | EEEEEEEEEEEEEEEE 63 | ................ 64 | ................ 65 | ................ 66 | ................ 67 | ................ 68 | ................ 69 | ................ 70 | ................ -------------------------------------------------------------------------------- /Docs/msx windows tiny sprite bkp 2.txt: -------------------------------------------------------------------------------- 1 | !type 2 | msx1 3 | #Slot 0 4 | ................ 5 | ................ 6 | ................ 7 | ................ 8 | ................ 9 | ................ 10 | .111111111111111 11 | .111111111111111 12 | .111111111....11 13 | .11111111..11..1 14 | .11111111..11..1 15 | .11111111..11..1 16 | .11111111..11..1 17 | .11111111..11..1 18 | .111111111....11 19 | .111111111111111 20 | #Slot 1 21 | ................ 22 | ................ 23 | ................ 24 | ................ 25 | ................ 26 | ................ 27 | 111111111111.... 28 | 1111......11.... 29 | 111.11111111.... 30 | 111.1.111.11111. 31 | 111.11.1.111111. 32 | 111.111.1111111. 33 | 111.11.1.111111. 34 | 111.1.111.11111. 35 | 111111111111111. 36 | 111111111111111. 37 | #Slot 2 38 | .1.............. 39 | .1.............. 40 | .1.............. 41 | .1.............. 42 | .1.............. 43 | .1.............. 44 | .1.............. 45 | .1.............. 46 | .1.............. 47 | .1.............. 48 | .1.............. 49 | .111111111111111 50 | ....111111111111 51 | ....111111111111 52 | ....111111111111 53 | ................ 54 | #Slot 3 55 | ...........1111. 56 | ...........1111. 57 | ...........1111. 58 | ...........1111. 59 | ...........1111. 60 | ..........11111. 61 | .........111111. 62 | ........11.1111. 63 | .......11.11111. 64 | ......11.111111. 65 | .....11.11.1111. 66 | 111111111111111. 67 | 111111111111111. 68 | 111111111111111. 69 | 111111111111111. 70 | ................ -------------------------------------------------------------------------------- /Apps/Paint/Data.s: -------------------------------------------------------------------------------- 1 | 2 | .PAINT_TOOLBAR: 3 | 4 | db TILE_EMPTY 5 | db TILE_EMPTY 6 | db TILE_LINE_VERTICAL 7 | 8 | ; -------------------------------- 9 | 10 | ; ----- 11 | db TILE_COLOR_1 ; 0 12 | db TILE_COLOR_1 13 | db TILE_LINE_VERTICAL 14 | 15 | ; ----- 16 | db TILE_COLOR_2 17 | db TILE_COLOR_3 18 | db TILE_LINE_VERTICAL 19 | 20 | ; ----- 21 | db TILE_COLOR_4 22 | db TILE_COLOR_5 23 | db TILE_LINE_VERTICAL 24 | 25 | ; ----- 26 | db TILE_COLOR_6 27 | db TILE_COLOR_7 28 | db TILE_LINE_VERTICAL 29 | 30 | ; ----- 31 | db TILE_COLOR_8 32 | db TILE_COLOR_9 33 | db TILE_LINE_VERTICAL 34 | 35 | ; ----- 36 | db TILE_COLOR_10 37 | db TILE_COLOR_11 38 | db TILE_LINE_VERTICAL 39 | 40 | ; ----- 41 | db TILE_COLOR_12 42 | db TILE_COLOR_13 43 | db TILE_LINE_VERTICAL 44 | 45 | ; ----- 46 | db TILE_COLOR_14 47 | db TILE_COLOR_15 48 | db TILE_LINE_VERTICAL 49 | 50 | ; -------------------------------- 51 | 52 | db TILE_EMPTY 53 | db TILE_EMPTY 54 | db TILE_LINE_VERTICAL 55 | 56 | ; ----- 57 | db TILE_EMPTY 58 | db TILE_EMPTY 59 | db TILE_LINE_VERTICAL 60 | 61 | ; ----- 62 | db TILE_EMPTY 63 | db TILE_EMPTY 64 | db TILE_LINE_VERTICAL 65 | 66 | ; ----- 67 | db TILE_EMPTY 68 | db TILE_EMPTY 69 | db TILE_LINE_VERTICAL 70 | 71 | 72 | ; ----------------------------------------- 73 | 74 | PAINT_VARS: 75 | .CURRENT_COLOR: equ 0 76 | -------------------------------------------------------------------------------- /Apps/Calc/Icon.s: -------------------------------------------------------------------------------- 1 | DB 00000000b 2 | DB 00000000b 3 | DB 00111111b 4 | DB 01000000b 5 | DB 01011111b 6 | DB 01010000b 7 | DB 01011111b 8 | DB 01000000b 9 | 10 | DB 01001001b 11 | DB 01011011b 12 | DB 01000000b 13 | DB 01001001b 14 | DB 01011011b 15 | DB 01000000b 16 | DB 01001001b 17 | DB 01011011b 18 | 19 | DB 01000000b 20 | DB 00111111b 21 | DB 00011111b 22 | DB 00000000b 23 | DB 00000000b 24 | DB 00000000b 25 | DB 00000000b 26 | DB 00000000b 27 | 28 | DB 00000000b 29 | DB 00000000b 30 | DB 11111111b 31 | DB 00000000b 32 | DB 11111000b 33 | DB 00001000b 34 | DB 11111000b 35 | DB 00000000b 36 | 37 | DB 00100100b 38 | DB 01101101b 39 | DB 00000000b 40 | DB 00100100b 41 | DB 01101101b 42 | DB 00000000b 43 | DB 00100100b 44 | DB 01101101b 45 | 46 | DB 00000000b 47 | DB 11111111b 48 | DB 11111111b 49 | DB 00000000b 50 | DB 00000000b 51 | DB 00000000b 52 | DB 00000000b 53 | DB 00000000b 54 | 55 | DB 00000000b 56 | DB 00000000b 57 | DB 11111000b 58 | DB 00000100b 59 | DB 00000110b 60 | DB 00000110b 61 | DB 00000110b 62 | DB 00000110b 63 | 64 | DB 10010110b 65 | DB 10110110b 66 | DB 00000110b 67 | DB 10010110b 68 | DB 10110110b 69 | DB 00000110b 70 | DB 00010110b 71 | DB 11110110b 72 | 73 | DB 00000110b 74 | DB 11111110b 75 | DB 11111100b 76 | DB 00000000b 77 | DB 00000000b 78 | DB 00000000b 79 | DB 00000000b 80 | DB 00000000b 81 | -------------------------------------------------------------------------------- /Apps/Notepad/Icon.s: -------------------------------------------------------------------------------- 1 | ;----- 2 | DB 00000000b 3 | DB 00000001b 4 | DB 00000010b 5 | DB 00000010b 6 | DB 00000100b 7 | DB 00000100b 8 | DB 00001000b 9 | DB 00001000b 10 | 11 | DB 00010001b 12 | DB 00010000b 13 | DB 00100000b 14 | DB 00100000b 15 | DB 01000000b 16 | DB 01000000b 17 | DB 10000000b 18 | DB 10000000b 19 | 20 | DB 10000000b 21 | DB 01111111b 22 | DB 00000000b 23 | DB 00000000b 24 | DB 00000000b 25 | DB 00000000b 26 | DB 00000000b 27 | DB 00000000b 28 | 29 | ;----- 30 | 31 | DB 01101101b 32 | DB 10110110b 33 | DB 01001001b 34 | DB 00000000b 35 | DB 00000000b 36 | DB 00000000b 37 | DB 11111111b 38 | DB 00000000b 39 | 40 | DB 11111110b 41 | DB 00000000b 42 | DB 00000000b 43 | DB 00000000b 44 | DB 00000000b 45 | DB 00000001b 46 | DB 00000001b 47 | DB 00000010b 48 | 49 | DB 00000010b 50 | DB 11111101b 51 | DB 10000000b 52 | DB 10111111b 53 | DB 10000000b 54 | DB 10101010b 55 | DB 01111111b 56 | DB 00111111b 57 | 58 | ; ----- 59 | DB 10110000b 60 | DB 11011100b 61 | DB 00100110b 62 | DB 00001011b 63 | DB 00001011b 64 | DB 00010011b 65 | DB 00010111b 66 | DB 00100011b 67 | 68 | DB 00100111b 69 | DB 01010011b 70 | DB 01000111b 71 | DB 10110011b 72 | DB 10000111b 73 | DB 01110011b 74 | DB 00000111b 75 | DB 11110011b 76 | 77 | DB 00000111b 78 | DB 11110011b 79 | DB 00000111b 80 | DB 11110011b 81 | DB 00000111b 82 | DB 10101111b 83 | DB 11111110b 84 | DB 11111100b 85 | -------------------------------------------------------------------------------- /Apps/Paint/Icon.s: -------------------------------------------------------------------------------- 1 | ;----- 2 | DB 00000000b 3 | DB 00000011b 4 | DB 00001100b 5 | DB 00010001b 6 | DB 00100011b 7 | DB 00100011b 8 | DB 00100001b 9 | DB 01000000b 10 | 11 | DB 01001110b 12 | DB 01001111b 13 | DB 01011111b 14 | DB 01011111b 15 | DB 01000000b 16 | DB 01000001b 17 | DB 00100011b 18 | DB 00100011b 19 | 20 | DB 00010011b 21 | DB 00010000b 22 | DB 00001000b 23 | DB 00000110b 24 | DB 00000011b 25 | DB 00000110b 26 | DB 00001100b 27 | DB 00000000b 28 | 29 | ;----- 30 | 31 | DB 00000000b 32 | DB 11110000b 33 | DB 00001100b 34 | DB 11000110b 35 | DB 11100011b 36 | DB 11100001b 37 | DB 11000001b 38 | DB 00000000b 39 | DB 00000011b 40 | DB 00000100b 41 | DB 10001001b 42 | DB 00001010b 43 | DB 00000101b 44 | DB 10000011b 45 | DB 10000000b 46 | DB 11000011b 47 | 48 | 49 | DB 11001111b 50 | DB 11001111b 51 | DB 00000111b 52 | DB 00000000b 53 | 54 | DB 11111111b 55 | DB 11111111b 56 | DB 00000000b 57 | DB 00000000b 58 | ;----- 59 | 60 | DB 00000000b 61 | DB 00000100b 62 | DB 00000110b 63 | DB 00000110b 64 | DB 00001010b 65 | DB 00010110b 66 | DB 10011110b 67 | DB 10101100b 68 | 69 | DB 11010000b 70 | DB 11100000b 71 | DB 01110000b 72 | DB 11011000b 73 | DB 01001100b 74 | DB 10001100b 75 | DB 00001100b 76 | DB 00001100b 77 | 78 | DB 10011100b 79 | DB 00111000b 80 | DB 01110000b 81 | DB 11100000b 82 | DB 11000000b 83 | DB 10000000b 84 | DB 00000000b 85 | DB 00000000b 86 | 87 | ;----- 88 | -------------------------------------------------------------------------------- /System/Process/SetCurrentProcess.s: -------------------------------------------------------------------------------- 1 | ; Input: 2 | ; HL = addr of process header 3 | _SET_CURRENT_PROCESS: 4 | 5 | ; TODO: 6 | ; if is there a current process, run "LoseFocus" event of it 7 | 8 | ; set curr proc to process 9 | ld (OS.currentProcessAddr), hl 10 | 11 | push hl ; IX = HL 12 | pop ix 13 | 14 | push hl 15 | ; get RAM variables area of this process 16 | ld l, (ix + PROCESS_STRUCT_IX.ramStartAddr) 17 | ld h, (ix + PROCESS_STRUCT_IX.ramStartAddr + 1) 18 | 19 | push hl ; IY = HL 20 | pop iy 21 | 22 | 23 | 24 | ; run process "GetFocus" event 25 | ld e, (ix + PROCESS_STRUCT_IX.getFocusAddr) ; process.GetFocus addr (low) 26 | ld d, (ix + PROCESS_STRUCT_IX.getFocusAddr + 1) ; process.GetFocus addr (high) 27 | call JP_DE 28 | pop hl 29 | 30 | push hl 31 | ; get layer number 32 | ld c, (ix + PROCESS_STRUCT_IX.layer) 33 | 34 | ; dec layer of all processes with layer > old layer 35 | call _ADJUST_LAYER_OF_PROCESSES 36 | 37 | ; set the new current layer to NUMBER_OF_PROCESSES - 1 38 | call _GET_NUMBER_OF_PROCESSES_OPENED 39 | dec a 40 | ld (ix + PROCESS_STRUCT_IX.layer), a 41 | pop hl 42 | 43 | call _UPDATE_SCREEN 44 | 45 | call _DRAW_TASKBAR 46 | 47 | ; ; TODO 48 | ; push hl ; ix = hl 49 | ; pop ix 50 | ; call _DRAW_WINDOW 51 | 52 | ; TODO 53 | ; place tile on window title to show it is the active window 54 | 55 | ret 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Apps/Template/Icon.s: -------------------------------------------------------------------------------- 1 | ;----- 2 | DB 11111111b 3 | DB 11111111b 4 | DB 11111111b 5 | DB 11111111b 6 | DB 11111111b 7 | DB 11111111b 8 | DB 11111111b 9 | DB 11111111b 10 | 11 | DB 00000001b 12 | DB 00000001b 13 | DB 00000001b 14 | DB 00000001b 15 | DB 00000001b 16 | DB 00000001b 17 | DB 00000001b 18 | DB 11111111b 19 | 20 | DB 00000001b 21 | DB 00000001b 22 | DB 00000001b 23 | DB 00000001b 24 | DB 00000001b 25 | DB 00000001b 26 | DB 00000001b 27 | DB 00000000b 28 | 29 | 30 | ;----- 31 | 32 | DB 00000001b 33 | DB 00000001b 34 | DB 00000001b 35 | DB 00000001b 36 | DB 00000001b 37 | DB 00000001b 38 | DB 00000001b 39 | DB 11111111b 40 | 41 | DB 00000001b 42 | DB 00111001b 43 | DB 01000101b 44 | DB 01000101b 45 | DB 01000101b 46 | DB 00111001b 47 | DB 00000001b 48 | DB 11111111b 49 | 50 | DB 00000001b 51 | DB 01000101b 52 | DB 00101001b 53 | DB 00010001b 54 | DB 00101001b 55 | DB 01000101b 56 | DB 00000001b 57 | DB 00000000b 58 | 59 | ;----- 60 | 61 | DB 00000000b 62 | DB 00000000b 63 | DB 00000000b 64 | DB 00000000b 65 | DB 00000000b 66 | DB 00000000b 67 | DB 00000000b 68 | DB 11111110b 69 | 70 | DB 00000000b 71 | DB 00000000b 72 | DB 00000000b 73 | DB 00000000b 74 | DB 00000000b 75 | DB 00000000b 76 | DB 00000000b 77 | DB 11111110b 78 | 79 | DB 00000000b 80 | DB 00000000b 81 | DB 00000000b 82 | DB 00000000b 83 | DB 00000000b 84 | DB 00000000b 85 | DB 00000000b 86 | DB 00000000b 87 | 88 | ;----- 89 | -------------------------------------------------------------------------------- /Apps/TicTacToe/Icon.s: -------------------------------------------------------------------------------- 1 | ;----- 2 | DB 00000001b 3 | DB 01000101b 4 | DB 00101001b 5 | DB 00010001b 6 | DB 00101001b 7 | DB 01000101b 8 | DB 00000001b 9 | DB 11111111b 10 | 11 | DB 00000001b 12 | DB 00000001b 13 | DB 00000001b 14 | DB 00000001b 15 | DB 00000001b 16 | DB 00000001b 17 | DB 00000001b 18 | DB 11111111b 19 | 20 | DB 00000001b 21 | DB 00000001b 22 | DB 00000001b 23 | DB 00000001b 24 | DB 00000001b 25 | DB 00000001b 26 | DB 00000001b 27 | DB 00000000b 28 | 29 | 30 | ;----- 31 | 32 | DB 00000001b 33 | DB 00000001b 34 | DB 00000001b 35 | DB 00000001b 36 | DB 00000001b 37 | DB 00000001b 38 | DB 00000001b 39 | DB 11111111b 40 | 41 | DB 00000001b 42 | DB 00111001b 43 | DB 01000101b 44 | DB 01000101b 45 | DB 01000101b 46 | DB 00111001b 47 | DB 00000001b 48 | DB 11111111b 49 | 50 | DB 00000001b 51 | DB 01000101b 52 | DB 00101001b 53 | DB 00010001b 54 | DB 00101001b 55 | DB 01000101b 56 | DB 00000001b 57 | DB 00000000b 58 | 59 | ;----- 60 | 61 | DB 00000000b 62 | DB 00000000b 63 | DB 00000000b 64 | DB 00000000b 65 | DB 00000000b 66 | DB 00000000b 67 | DB 00000000b 68 | DB 11111110b 69 | 70 | DB 00000000b 71 | DB 00000000b 72 | DB 00000000b 73 | DB 00000000b 74 | DB 00000000b 75 | DB 00000000b 76 | DB 00000000b 77 | DB 11111110b 78 | 79 | DB 00000000b 80 | DB 00000000b 81 | DB 00000000b 82 | DB 00000000b 83 | DB 00000000b 84 | DB 00000000b 85 | DB 00000000b 86 | DB 00000000b 87 | 88 | ;----- 89 | -------------------------------------------------------------------------------- /System/Window/SetCustomTile.s: -------------------------------------------------------------------------------- 1 | ; Set custom tiles (tiles specific for this process) 2 | ; Inputs: 3 | ; IX: process address 4 | ; A: tile number (between 0 and 11, relative to this process) 5 | ; HL: pattern address on RAM 6 | ; DE: color address on RAM 7 | SET_CUSTOM_TILE: 8 | 9 | ld b, (ix + PROCESS_STRUCT_IX.vramStartTile) 10 | add b 11 | 12 | ld (OS.tempWord), hl 13 | ld (OS.tempWord_2), de 14 | 15 | ; --- tile pattern 16 | ; calc PATTBL/COLTBL addr for custom tile 17 | ld h, 0 18 | ld l, a 19 | 20 | add hl, hl ; multiply HL by 8 21 | add hl, hl 22 | add hl, hl 23 | 24 | ld c, PORT_0 25 | 26 | ex de, hl ; DE = delta addr for PATTBL and COLTBL of this tile 27 | 28 | ld b, 3 ; repeat for the 3 parts of the screen 29 | .loop: 30 | push bc 31 | ld hl, PATTBL 32 | add hl, de 33 | 34 | call BIOS_SETWRT 35 | 36 | ld hl, (OS.tempWord) 37 | ld b, 8 38 | .innerLoop: 39 | outi 40 | jp nz, .innerLoop ; this uses exactly 29 cycles (t-states) 41 | 42 | 43 | ; tile colors 44 | ld hl, COLTBL 45 | add hl, de 46 | 47 | call BIOS_SETWRT 48 | 49 | ld hl, (OS.tempWord_2) 50 | ld b, 8 51 | .innerLoop_1: 52 | outi 53 | jp nz, .innerLoop_1 ; this uses exactly 29 cycles (t-states) 54 | 55 | ; go to next third of screen 56 | ; DE += 256 * 8 57 | ex de, hl 58 | ld de, 256 * 8 59 | add hl, de 60 | ex de, hl 61 | pop bc 62 | 63 | djnz .loop 64 | 65 | ret -------------------------------------------------------------------------------- /Apps/Tetra/Icon.s: -------------------------------------------------------------------------------- 1 | ;----- 2 | 3 | DB 11111111 b 4 | DB 10001111 b 5 | DB 10001111 b 6 | DB 10001111 b 7 | DB 11111111 b 8 | DB 10001000 b 9 | DB 10001000 b 10 | DB 10001000 b 11 | 12 | DB 11111111 b 13 | DB 10001111 b 14 | DB 10001111 b 15 | DB 10001111 b 16 | DB 11111111 b 17 | DB 11111111 b 18 | DB 11111111 b 19 | DB 11111111 b 20 | 21 | DB 11111111 b 22 | DB 11111000 b 23 | DB 11111000 b 24 | DB 11111000 b 25 | DB 11111111 b 26 | DB 11111000 b 27 | DB 11111000 b 28 | DB 11111000 b 29 | 30 | 31 | ;----- 32 | 33 | 34 | DB 11111111 b 35 | DB 11111111 b 36 | DB 11111111 b 37 | DB 11111111 b 38 | DB 11111111 b 39 | DB 11111111 b 40 | DB 11111111 b 41 | DB 11111111 b 42 | 43 | DB 11111111 b 44 | DB 11111111 b 45 | DB 11111111 b 46 | DB 11111111 b 47 | DB 11111111 b 48 | DB 11111111 b 49 | DB 11111111 b 50 | DB 11111111 b 51 | 52 | DB 11111111 b 53 | DB 10001111 b 54 | DB 10001111 b 55 | DB 10001111 b 56 | DB 11111111 b 57 | DB 10001111 b 58 | DB 10001111 b 59 | DB 10001111 b 60 | 61 | ;----- 62 | 63 | DB 11111111 b 64 | DB 11111111 b 65 | DB 11111111 b 66 | DB 11111111 b 67 | DB 11111111 b 68 | DB 11111111 b 69 | DB 11111111 b 70 | DB 11111111 b 71 | 72 | DB 11111111 b 73 | DB 10001111 b 74 | DB 10001111 b 75 | DB 10001111 b 76 | DB 11111111 b 77 | DB 10001000 b 78 | DB 10001000 b 79 | DB 10001000 b 80 | 81 | 82 | DB 11111111 b 83 | DB 11111000 b 84 | DB 11111000 b 85 | DB 11111000 b 86 | DB 11111111 b 87 | DB 11111111 b 88 | DB 11111111 b 89 | DB 11111111 b 90 | 91 | ;----- 92 | -------------------------------------------------------------------------------- /System/Process/MinimizeProcess.s: -------------------------------------------------------------------------------- 1 | ; Input: 2 | ; HL = addr of process header 3 | _MINIMIZE_PROCESS: 4 | 5 | ; IX = HL 6 | push hl 7 | pop ix 8 | 9 | ; if (windowState == MINIMIZED) ret 10 | ld a, (ix + PROCESS_STRUCT_IX.windowState) 11 | cp WINDOW_STATE.MINIMIZED 12 | ret z 13 | 14 | ; save window state 15 | ld (ix + PROCESS_STRUCT_IX.previousWindowState), a 16 | 17 | ; set status = minimized 18 | ld a, WINDOW_STATE.MINIMIZED 19 | ld (ix + PROCESS_STRUCT_IX.windowState), a 20 | 21 | push ix 22 | 23 | ; if it is the current process, set current process to null 24 | ld hl, (OS.currentProcessAddr) 25 | push ix ; DE = IX 26 | pop de 27 | call BIOS_DCOMPR ; Compare Contents Of HL & DE, Set Z-Flag IF (HL == DE), Set CY-Flag IF (HL < DE) 28 | jp nz, .skip_1 29 | 30 | ld hl, 0x0000 31 | ld (OS.currentProcessAddr), hl 32 | .skip_1: 33 | 34 | pop ix 35 | 36 | call _CLOSE_WINDOW 37 | 38 | call _UPDATE_SCREEN 39 | 40 | call _DISABLE_MOUSE_OVER 41 | ; ; ---------- disable mouse over 42 | ; ; reset flag mouseOver_Activated 43 | ; xor a 44 | ; ld (OS.mouseOver_Activated), a 45 | 46 | ; ; reset mouseOver_screenMappingValue 47 | ; ld (OS.mouseOver_screenMappingValue), a 48 | 49 | ; ; get mouse over NAMTBL addr previously saved 50 | ; ld hl, (OS.mouseOver_NAMTBL_addr) 51 | ; call BIOS_SETWRT 52 | 53 | ; ld a, TILE_EMPTY 54 | ; out (PORT_0), a 55 | 56 | ; ld a, SCREEN_MAPPING_DESKTOP ; 255 57 | ; ld (OS.currentTileMouseOver), a 58 | ; ; ----------- 59 | 60 | 61 | call _DRAW_TASKBAR 62 | 63 | 64 | ret -------------------------------------------------------------------------------- /Docs/ram.txt: -------------------------------------------------------------------------------- 1 | OS: 2 | 3 | .mouseY: rb 1 4 | .mouseX: rb 1 5 | .mousePattern: rb 1 6 | .mouseColor: rb 1 7 | .mouseY_1: rb 1 8 | .mouseX_1: rb 1 9 | .mousePattern_1: rb 1 10 | .mouseColor_1: rb 1 11 | 12 | .keyboardMatrix: rb 10 ; https://map.grauw.nl/articles/keymatrix.php 13 | 14 | .ticksSinceLastInput: rw 1 ; used to trigger screen saver 15 | 16 | .currentTime: rb 3 ; BCD encoded time hh:mm:ss 17 | .currentDate: rb 3 ; BCD encoded date dd/mm/yyyy 18 | .timeCounter rb 1 ; 0-59 JIFFY based counter to increment time/date (0-49 on PAL machines) 19 | 20 | ; TODO: this can be moved to the free VRAM area (addr 7040) 21 | .screenMapping: rb 32*24 ; used to map each tile to a window/desktop (useful on mouse click/over). 22 | ; 255: desktop, 254: bottom bar; 23 | ; 4 high bits: window title buttons/resize corner, 4 lower bits (0-15): process id 24 | 25 | .currentProcessAddr: rw 1 26 | 27 | .processes: rb Process_struct.size * 4 28 | 29 | 30 | Process_struct: 31 | .processId: rb 1 ; 255: empty 32 | .windowState: rb 1 ; 0: minimized, 1: restored, 2: maximized 33 | .x: rb 1 34 | .y: rb 1 35 | .width: rb 1 36 | .height: rb 1 37 | .minWidth: rb 1 38 | .minHeight: rb 1 39 | 40 | .windowTitle: rb 16 41 | .isFixedSize: rb 1 42 | .vertScrollbarEnabled: rb 1 43 | .vertScrollbarPosition: rb 1 44 | 45 | 46 | .openAddr: rw 1 47 | .workAddr: rw 1 48 | .drawAddr: rw 1 49 | .clickAddr: rw 1 50 | .closeAddr: rw 1 51 | 52 | .ramStartAddr: rw 1 53 | .ramSize: rw 1 54 | 55 | .vramStartTileAddr: rw 1 56 | 57 | .screenTilesBehind: rb 32*24 58 | 59 | .size: equ $ - Process_struct 60 | 61 | 62 | 63 | 64 | --------------------- 65 | 66 | SC2 VRAM use: 67 | start 68 | PATTBL: 32*192 = 6144 0 69 | COLTBL: 32*192 = 6144 8192 70 | NAMTBL: 32*24 = 768 6144 71 | SPRPAT: 256*8 = 2048 14336 72 | SPRATR: 3284 = 128 6912 73 | 74 | free space: (6912+128) - 8192 = 7040 - 8192 (1152 bytes free) 75 | -------------------------------------------------------------------------------- /System/Time/Time.s: -------------------------------------------------------------------------------- 1 | _INIT_SYSTEM_TIME: 2 | 3 | xor a 4 | 5 | ld (os.timeCounter), a 6 | 7 | ; init system clock (3 bytes) 8 | ld a, 0x12 9 | ld (OS.currentTime_Hours), a 10 | xor a 11 | ld (OS.currentTime_Minutes), a 12 | ld (OS.currentTime_Seconds), a 13 | ld (OS.timeCounter), a 14 | 15 | ; reset system date (3 bytes) 16 | ld hl, OS.currentDate 17 | ld (hl), a 18 | inc hl 19 | ld (hl), a 20 | inc hl 21 | ld (hl), a 22 | 23 | ret 24 | 25 | 26 | 27 | SYSTEM_HERTZ_RATE: equ 60 ; or 50 28 | 29 | _UPDATE_SYSTEM_TIME: 30 | 31 | ld a, (os.timeCounter) 32 | inc a 33 | ld (os.timeCounter), a 34 | cp SYSTEM_HERTZ_RATE 35 | ret nz 36 | 37 | ; reset timeCounter 38 | xor a 39 | ld (os.timeCounter), a 40 | 41 | ;ld b, 0x01 ; 1 in BCD format 42 | 43 | ; update clock (add 1 second) 44 | ld a, (OS.currentTime_Seconds) 45 | inc a ;add a, b 46 | daa 47 | ld (OS.currentTime_Seconds), a 48 | 49 | ; update minute if seconds == 60 50 | cp 0x60 51 | ret nz 52 | ld a, (OS.currentTime_Minutes) 53 | inc a ;add a, b 54 | daa 55 | ld (OS.currentTime_Minutes), a 56 | ; reset seconds 57 | xor a 58 | ld (OS.currentTime_Seconds), a 59 | 60 | ; update hour if minutes == 60 61 | ld a, (OS.currentTime_Minutes) 62 | cp 0x60 63 | ret nz 64 | ld a, (OS.currentTime_Hours) 65 | inc a 66 | daa 67 | 68 | cp 0x13 ; if (Hours == 0x13) hours = 0x01 69 | jp nz, .not13Hours 70 | ld a, 0x01 71 | .not13Hours: 72 | ld (OS.currentTime_Hours), a 73 | ; reset minutes 74 | xor a 75 | ld (OS.currentTime_Minutes), a 76 | 77 | 78 | 79 | ret -------------------------------------------------------------------------------- /Include/MsxConstants.s: -------------------------------------------------------------------------------- 1 | PORT_0: equ 0x98 2 | PORT_1: equ 0x99 3 | PORT_2: equ 0x9a 4 | PORT_3: equ 0x9b 5 | 6 | 7 | ; PPI (Programmable Peripheral Interface) 8 | PPI.A: equ $a8 ; PPI port A: primary slot selection register 9 | ; 33221100: number of slot to select on page n 10 | PPI.B: equ $a9 ; PPI port B: read the keyboard matrix row specified via the PPI port C ($AA) 11 | PPI.C: equ $aa ; PPI port C: control keyboard CAP LED, data recorder signals, and keyboard matrix row 12 | ; bits 0-3: Row number of specified keyboard matrix to read via port B 13 | ; bit 4: Data recorder motor (reset to turn on) 14 | ; bit 5: Set to write on tape 15 | ; bit 6: Keyboard LED CAPS (reset to turn on) 16 | ; bit 7: 1, then 0 shortly thereafter to make a clicking sound (used for the keyboard) 17 | PPI.R: equ $ab ; PPI ports control register (write only) 18 | ; bit 0 = Bit status to change 19 | ; bit 1-3 = Number of the bit to change at port C of the PPI 20 | ; bit 4-6 = Unused 21 | ; bit 7 = Must be always reset on MSX 22 | 23 | 24 | ;RG0SAV equ 0F3DFH ; from MSX BIOS disassembled source (https://sourceforge.net/projects/msxsyssrc/) 25 | ; 26 | ; list of VDP registers and corresponding system variables: 27 | ; https://www.msx.org/wiki/Category:VDP_Registers 28 | REG0SAV: equ 0xF3DF 29 | REG1SAV: equ 0xF3E0 30 | REG2SAV: equ 0xF3E1 31 | REG3SAV: equ 0xF3E2 32 | REG4SAV: equ 0xF3E3 33 | REG5SAV: equ 0xF3E4 34 | REG6SAV: equ 0xF3E5 35 | REG7SAV: equ 0xF3E6 36 | 37 | REG8SAV: equ 0xFFE7 38 | REG9SAV: equ 0xFFE8 39 | REG10SAV: equ 0xFFE9 40 | REG11SAV: equ 0xFFEA 41 | REG12SAV: equ 0xFFEB 42 | REG13SAV: equ 0xFFEC 43 | REG14SAV: equ 0xFFED 44 | REG15SAV: equ 0xFFEE 45 | REG16SAV: equ 0xFFEF 46 | REG17SAV: equ 0xFFF0 47 | REG18SAV: equ 0xFFF1 48 | REG19SAV: equ 0xFFF2 49 | REG20SAV: equ 0xFFF3 50 | REG21SAV: equ 0xFFF4 51 | REG22SAV: equ 0xFFF5 52 | REG23SAV: equ 0xFFF6 53 | 54 | ;REG24SAV doesn't exist 55 | 56 | REG25SAV: equ 0xFFFA 57 | REG26SAV: equ 0xFFFB 58 | REG27SAV: equ 0xFFFC 59 | -------------------------------------------------------------------------------- /Apps/TicTacToe/Open.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | xor a 6 | ld hl, TicTacToe_Data.TILE_X_pattern_0 7 | ld de, TicTacToe_Data.TILE_X_colors 8 | call SET_CUSTOM_TILE 9 | 10 | ld a, 1 11 | ld hl, TicTacToe_Data.TILE_X_pattern_1 12 | ld de, TicTacToe_Data.TILE_X_colors 13 | call SET_CUSTOM_TILE 14 | 15 | ld a, 2 16 | ld hl, TicTacToe_Data.TILE_X_pattern_2 17 | ld de, TicTacToe_Data.TILE_X_colors 18 | call SET_CUSTOM_TILE 19 | 20 | ld a, 3 21 | ld hl, TicTacToe_Data.TILE_X_pattern_3 22 | ld de, TicTacToe_Data.TILE_X_colors 23 | call SET_CUSTOM_TILE 24 | 25 | 26 | 27 | ld a, 4 28 | ld hl, TicTacToe_Data.TILE_O_pattern_0 29 | ld de, TicTacToe_Data.TILE_O_colors 30 | call SET_CUSTOM_TILE 31 | 32 | ld a, 5 33 | ld hl, TicTacToe_Data.TILE_O_pattern_1 34 | ld de, TicTacToe_Data.TILE_O_colors 35 | call SET_CUSTOM_TILE 36 | 37 | ld a, 6 38 | ld hl, TicTacToe_Data.TILE_O_pattern_2 39 | ld de, TicTacToe_Data.TILE_O_colors 40 | call SET_CUSTOM_TILE 41 | 42 | ld a, 7 43 | ld hl, TicTacToe_Data.TILE_O_pattern_3 44 | ld de, TicTacToe_Data.TILE_O_colors 45 | call SET_CUSTOM_TILE 46 | 47 | 48 | 49 | ; init playfield 50 | xor a 51 | ld b, 9 52 | push iy 53 | .loop_1: 54 | ld (iy + TICTACTOE_VARS.PLAYFIELD), a 55 | inc iy 56 | djnz .loop_1 57 | pop iy 58 | 59 | 60 | ld a, 1 61 | ld (iy + TICTACTOE_VARS.CURRENT_PLAYER), a 62 | 63 | 64 | ; debug 65 | ; ld a, 1 66 | ; ld (iy + TICTACTOE_VARS.PLAYFIELD), a 67 | ; ld a, 2 68 | ; ld (iy + TICTACTOE_VARS.PLAYFIELD + 1), a 69 | ; ld a, 1 70 | ; ld (iy + TICTACTOE_VARS.PLAYFIELD + 2), a 71 | 72 | ; ld a, 1 73 | ; ld (iy + TICTACTOE_VARS.PLAYFIELD + 3), a 74 | ; ld a, 2 75 | ; ld (iy + TICTACTOE_VARS.PLAYFIELD + 4), a 76 | ; ld a, 0 77 | ; ld (iy + TICTACTOE_VARS.PLAYFIELD + 5), a 78 | 79 | ; ld a, 1 80 | ; ld (iy + TICTACTOE_VARS.PLAYFIELD + 6), a 81 | ; ld a, 2 82 | ; ld (iy + TICTACTOE_VARS.PLAYFIELD + 7), a 83 | ; ld a, 1 84 | ; ld (iy + TICTACTOE_VARS.PLAYFIELD + 8), a 85 | 86 | ret 87 | -------------------------------------------------------------------------------- /System/Window/DrawOnWindowUsefulArea.s: -------------------------------------------------------------------------------- 1 | ; TODO make this work with all possible HL values 2 | 3 | ; Input: 4 | ; IX = process header addr 5 | ; HL = ROM start source address (CAUTION, use only _GET_WINDOW_BASE_NAMTBL or _GET_WINDOW_BASE_NAMTBL + 1) 6 | ; DE = VRAM NAMTBL start destiny address 7 | ; B = line width (0-31) 8 | ; C = number of lines 9 | DRAW_ON_WINDOW_USEFUL_AREA: 10 | 11 | ld a, c 12 | ld (OS.tempVar_2), a 13 | 14 | ; ld iyh, 0 ; progressive line counter 15 | xor a 16 | ld (OS.tempVar_1), a 17 | 18 | .outerLoop: 19 | 20 | ld a, (ix + PROCESS_STRUCT_IX.windowState) 21 | cp WINDOW_STATE.RESTORED 22 | jp z, .isRestored 23 | 24 | ; check window height for maximized window 25 | ld a, 23 - 1 ; one line for title 26 | jp .checkHeight 27 | 28 | .isRestored: 29 | ; check window height for restored window 30 | ld a, (ix + PROCESS_STRUCT_IX.height) 31 | sub 3 ; two line for title, one line for bottom 32 | 33 | .checkHeight: 34 | ; cp iyh 35 | push hl 36 | ld hl, OS.tempVar_1 37 | cp (hl) 38 | pop hl 39 | ret z ; if (A == progressive line counter) ret 40 | ret c ; if (A < progressive line counter) ret 41 | 42 | push bc, hl, de 43 | 44 | ex de, hl ; invert DE and HL 45 | 46 | push hl, de 47 | call BIOS_SETWRT 48 | pop hl, de ; invert DE and HL again 49 | 50 | ld c, PORT_0 51 | .innerLoop: 52 | ; TODO: check window width (caution: look input HL for more info) 53 | outi 54 | jp nz, .innerLoop ; this uses exactly 29 cycles (t-states) 55 | 56 | pop de 57 | 58 | ; DE += 32 59 | ex de, hl 60 | ld bc, 32 61 | add hl, bc 62 | ex de, hl 63 | 64 | pop hl 65 | pop bc 66 | 67 | ; HL += B (line width) 68 | ld c, b 69 | ld b, 0 70 | add hl, bc 71 | ld b, c 72 | 73 | ; inc iyh ; progressive line counter 74 | ld a, (OS.tempVar_1) ; progressive line counter 75 | inc a 76 | ld (OS.tempVar_1), a 77 | 78 | ; dec iyl ; dec line counter 79 | ld a, (OS.tempVar_2) ; dec line counter 80 | dec a 81 | ld (OS.tempVar_2), a 82 | jp nz, .outerLoop 83 | 84 | ret -------------------------------------------------------------------------------- /Apps/TicTacToe/Draw.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | call GET_USEFUL_WINDOW_BASE_NAMTBL 6 | 7 | ex de, hl 8 | 9 | ; draw playfield 10 | ld hl, TicTacToe_Data.PLAYFIELD_TILES ; RAM address (source) 11 | ld b, 8 ; size of line 12 | ld c, 10 ; number of lines 13 | call DRAW_ON_WINDOW_USEFUL_AREA 14 | 15 | ; ; debug 16 | ; call GET_USEFUL_WINDOW_BASE_NAMTBL 17 | 18 | ; call BIOS_SETWRT 19 | ; ld a, (ix + PROCESS_STRUCT_IX.vramStartTile) 20 | ; out (PORT_0), a 21 | 22 | ; inc a 23 | ; out (PORT_0), a 24 | 25 | 26 | ; read playfield array and update screen 27 | call GET_USEFUL_WINDOW_BASE_NAMTBL 28 | ld de, 64 ; 2 lines below 29 | add hl, de 30 | ld c, 3 ; 3 lines of playfield 31 | push iy 32 | .loop_2: 33 | push hl 34 | ld b, 3 ; 3 columns of playfield 35 | .loop_1: 36 | push hl 37 | ld a, (iy + TICTACTOE_VARS.PLAYFIELD) 38 | or a 39 | jp z, .next 40 | 41 | cp 1 42 | jp z, .draw_X 43 | 44 | cp 2 45 | jp z, .draw_O 46 | 47 | .next: 48 | pop hl 49 | 50 | inc iy 51 | ld de, 3 52 | add hl, de 53 | djnz .loop_1 54 | pop hl 55 | ld de, 32 * 3 ; 3 lines below 56 | add hl, de 57 | dec c 58 | jp nz, .loop_2 59 | pop iy 60 | 61 | 62 | ret 63 | 64 | .draw_O: 65 | ld a, (ix + PROCESS_STRUCT_IX.vramStartTile) 66 | add 4 67 | jp .drawPiece 68 | 69 | .draw_X: 70 | 71 | ld a, (ix + PROCESS_STRUCT_IX.vramStartTile) 72 | jp .drawPiece 73 | 74 | .drawPiece: 75 | push af 76 | call BIOS_SETWRT 77 | pop af 78 | 79 | out (PORT_0), a 80 | 81 | ld de, 32 82 | add hl, de ;go to next line 83 | 84 | inc a 85 | out (PORT_0), a 86 | 87 | 88 | push af 89 | call BIOS_SETWRT 90 | pop af 91 | 92 | ; ld a, (ix + PROCESS_STRUCT_IX.vramStartTile) 93 | 94 | inc a 95 | out (PORT_0), a 96 | 97 | nop 98 | nop 99 | nop 100 | inc a 101 | out (PORT_0), a 102 | 103 | jp .next -------------------------------------------------------------------------------- /Apps/Settings/Click.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | ; HL = click position in tiles relative to window useful area top left, L = column, H = line 5 | 6 | 7 | 8 | ; ------------- click on tabs 9 | 10 | ; if (y > 2) ret 11 | ld a, h 12 | cp 2 + 1 13 | jp nc, .notClickOnTabs ; ret nc 14 | 15 | 16 | ; if (x <= 5) .ClickTab_Video 17 | ld a, l 18 | cp 5 + 1 19 | jp nc, .continue_1 20 | 21 | jp .ClickTab_Video 22 | 23 | .continue_1: 24 | 25 | ; if (x <= 11) .ClickTab_Mouse 26 | ld a, l 27 | cp 11 + 1 28 | jp nc, .continue_2 29 | 30 | jp .ClickTab_Mouse 31 | 32 | .continue_2: 33 | 34 | ; if (x <= 16) .ClickTab_Time 35 | ld a, l 36 | cp 16 + 1 37 | jp nc, .continue_3 38 | 39 | jp .ClickTab_Time 40 | 41 | .continue_3: 42 | 43 | 44 | 45 | ret 46 | 47 | .notClickOnTabs: 48 | 49 | ld a, (iy + SETTINGS_VARS.TAB_SELECTED) 50 | cp SETTINGS_TABS_VALUES.TAB_TIME 51 | jp z, .isOnTimeTab 52 | 53 | ret 54 | 55 | .isOnTimeTab: 56 | 57 | ; check if click is on checkbox ShowTicks 58 | ; if (y != 7) ret 59 | ld a, h 60 | cp 7 61 | ret nz 62 | 63 | ; if (x != 2) ret 64 | ld a, l 65 | cp 2 66 | ret nz 67 | 68 | ; ; if (x < ?) ret 69 | ; ld a, l 70 | ; cp ? 71 | ; ret c 72 | 73 | ; ; if (x >= ?) ret 74 | ; ld a, l 75 | ; cp ? 76 | ; ret nc 77 | 78 | ; if (CHECKBOX_SHOW_TICKS_VALUE == 0) setCheckbox; 79 | ld a, (iy + SETTINGS_VARS.CHECKBOX_SHOW_TICKS_VALUE) 80 | or a 81 | jp z, .setCheckbox 82 | 83 | ; else resetCheckbox; 84 | xor a 85 | ld (iy + SETTINGS_VARS.CHECKBOX_SHOW_TICKS_VALUE), a 86 | 87 | jp .return 88 | 89 | .setCheckbox: 90 | ld a, 1 91 | ld (iy + SETTINGS_VARS.CHECKBOX_SHOW_TICKS_VALUE), a 92 | jp .return 93 | 94 | .ClickTab_Video: 95 | ld a, SETTINGS_TABS_VALUES.TAB_VIDEO 96 | ld (iy + SETTINGS_VARS.TAB_SELECTED), a 97 | jp .return 98 | 99 | .ClickTab_Mouse: 100 | ld a, SETTINGS_TABS_VALUES.TAB_MOUSE 101 | ld (iy + SETTINGS_VARS.TAB_SELECTED), a 102 | jp .return 103 | 104 | .ClickTab_Time: 105 | ld a, SETTINGS_TABS_VALUES.TAB_TIME 106 | ld (iy + SETTINGS_VARS.TAB_SELECTED), a 107 | jp .return 108 | 109 | .return: 110 | ; call "Draw" event of this process 111 | ld e, (ix + PROCESS_STRUCT_IX.drawAddr) ; process.Draw addr (low) 112 | ld d, (ix + PROCESS_STRUCT_IX.drawAddr + 1) ; process.Draw addr (high) 113 | call JP_DE 114 | ret 115 | -------------------------------------------------------------------------------- /Apps/Notepad/Work.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | call BIOS_CHSNS ; Tests the status of the keyboard buffer; Output: Zero flag set if buffer is empty, otherwise not set 6 | jp z, .return ; ret z 7 | 8 | call BIOS_CHGET 9 | ; check lowercase ASCII chars (97-122) 10 | ; if (A < 97) ret 11 | cp 97 12 | ret c 13 | ; if (A >= 122 + 1) ret 14 | cp 122 + 1 15 | ret nc 16 | 17 | ; ld d, a ; save char of keypressed 18 | 19 | 20 | 21 | ; ; if(keypressed) ret 22 | ; ld a, (iy + NOTEPAD_VARS.KEYPRESSED) 23 | ; or a 24 | ; ret nz 25 | 26 | 27 | 28 | ; ld a, 1 29 | ; ld (iy + NOTEPAD_VARS.KEYPRESSED), a 30 | 31 | 32 | ; ld a, d ; restore char of keypressed 33 | 34 | 35 | ; A = A - ASCII_CODE_LOWERCASE_A + TILE_FONT_LOWERCASE_A 36 | ld b, TILE_FONT_LOWERCASE_A - ASCII_CODE_LOWERCASE_A 37 | add b 38 | 39 | ; put A value in current cursor position 40 | ld d, 0 41 | ld e, (iy + NOTEPAD_VARS.CURSOR_POSITION) 42 | push iy 43 | add iy, de 44 | ld (iy + NOTEPAD_VARS.TEXT_START), a 45 | pop iy 46 | 47 | ; cursor++ 48 | inc (iy + NOTEPAD_VARS.CURSOR_POSITION) 49 | 50 | ; put TEXT_END_OF_FILE value in current cursor position 51 | ld a, TEXT_END_OF_FILE 52 | ld d, 0 53 | ld e, (iy + NOTEPAD_VARS.CURSOR_POSITION) 54 | push iy 55 | add iy, de 56 | ld (iy + NOTEPAD_VARS.TEXT_START), a 57 | pop iy 58 | 59 | 60 | ; call "Draw" event of this process 61 | ld e, (ix + PROCESS_STRUCT_IX.drawAddr) ; process.Draw addr (low) 62 | ld d, (ix + PROCESS_STRUCT_IX.drawAddr + 1) ; process.Draw addr (high) 63 | call JP_DE 64 | 65 | ; get base NAMTBL of the window 66 | ; ; push hl ; ix = hl 67 | ; ; pop ix 68 | ; ld l, (ix + PROCESS_STRUCT_IX.x) ; process.x 69 | ; ld h, (ix + PROCESS_STRUCT_IX.y) ; process.y 70 | ; call _CONVERT_COL_LINE_TO_LINEAR 71 | 72 | ; ld bc, NAMTBL + (32 * 5) + 1 ; 5 lines below and one column right 73 | ; add hl, bc 74 | 75 | ; call _GET_WINDOW_BASE_NAMTBL 76 | 77 | 78 | ; ; debug 79 | ; ; write a test char (units of seconds from system time) 80 | 81 | ; ; two lines below 82 | ; ld bc, 32 * 2 83 | ; add hl, bc 84 | 85 | ; ld de, TEST_NOTEPAD_WORK_EVENT_STRING 86 | ; call _DRAW_STRING 87 | 88 | ; call BIOS_SETWRT 89 | ; ld a, (OS.currentTime_Seconds) 90 | ; and 0000 1111 b ; get only low nibble (0-10 in BCD) 91 | 92 | ; ld b, TILE_FONT_NUMBERS_0 + 0 93 | ; add b 94 | ; out (PORT_0), a 95 | 96 | ret 97 | 98 | .return: 99 | ; xor a 100 | ; ld (iy + NOTEPAD_VARS.KEYPRESSED), a 101 | 102 | ret -------------------------------------------------------------------------------- /System/Process/CloseProcess.s: -------------------------------------------------------------------------------- 1 | ; Input: 2 | ; HL = addr of process header 3 | _CLOSE_PROCESS: 4 | 5 | ; IX = HL 6 | push hl 7 | pop ix 8 | 9 | ; call process "Close" event 10 | push hl 11 | 12 | ; get RAM variables area of this process 13 | ld l, (ix + PROCESS_STRUCT_IX.ramStartAddr) 14 | ld h, (ix + PROCESS_STRUCT_IX.ramStartAddr + 1) 15 | 16 | push hl ; IY = HL 17 | pop iy 18 | 19 | 20 | ld e, (ix + PROCESS_STRUCT_IX.closeAddr) ; process.Close addr (low) 21 | ld d, (ix + PROCESS_STRUCT_IX.closeAddr + 1) ; process.Close addr (high) 22 | call JP_DE 23 | pop hl 24 | 25 | ; decrease layer number of all processes with layer > this.layer 26 | push hl 27 | ld c, (ix + PROCESS_STRUCT_IX.layer) 28 | call _ADJUST_LAYER_OF_PROCESSES 29 | pop hl 30 | 31 | 32 | push hl 33 | call _CLOSE_WINDOW 34 | pop hl 35 | 36 | 37 | 38 | 39 | ; --- clear variables area of this process slot 40 | push hl 41 | xor a 42 | ld (iy + 0), a 43 | 44 | push iy ; HL = IY 45 | pop hl 46 | 47 | push hl 48 | inc hl ; DE = HL + 1 49 | push hl 50 | pop de 51 | pop hl 52 | 53 | ld bc, OS.PROCESS_VARS_AREA_SIZE - 1 54 | ldir 55 | pop hl 56 | 57 | 58 | push hl 59 | ; ------ clear this process slot (fill with 0xff) 60 | ld a, 0xff 61 | ; ld hl, (OS.currentProcessAddr) 62 | ld (hl), a 63 | 64 | push hl ; DE = HL 65 | pop de 66 | 67 | inc de 68 | 69 | ; ld hl, ? 70 | ; ld de, ? 71 | ld bc, Process_struct.size - 1 72 | 73 | ldir 74 | ; ------- 75 | pop hl 76 | 77 | 78 | 79 | call _DISABLE_MOUSE_OVER 80 | ; ; ---------- disable mouse over 81 | ; ; reset flag mouseOver_Activated 82 | ; xor a 83 | ; ld (OS.mouseOver_Activated), a 84 | 85 | ; ; reset mouseOver_screenMappingValue 86 | ; ld (OS.mouseOver_screenMappingValue), a 87 | 88 | ; ; get mouse over NAMTBL addr previously saved 89 | ; ld hl, (OS.mouseOver_NAMTBL_addr) 90 | ; call BIOS_SETWRT 91 | 92 | ; ld a, TILE_EMPTY 93 | ; out (PORT_0), a 94 | 95 | ; ld a, SCREEN_MAPPING_DESKTOP ; 255 96 | ; ld (OS.currentTileMouseOver), a 97 | ; ; ----------- 98 | 99 | 100 | 101 | call _UPDATE_SCREEN 102 | 103 | 104 | call _DRAW_TASKBAR 105 | 106 | ; set nextAvailableProcessAddr 107 | call _GET_NEXT_AVAILABLE_PROCESS_ADDR 108 | ld (OS.nextAvailableProcessAddr), hl 109 | 110 | 111 | 112 | ; set current process to null 113 | ld hl, 0x0000 114 | ld (OS.currentProcessAddr), hl 115 | 116 | 117 | 118 | ret 119 | -------------------------------------------------------------------------------- /Apps/Template/Header.s: -------------------------------------------------------------------------------- 1 | Tetra: 2 | 3 | ; fixed values for app initialization 4 | .Header: 5 | 6 | .processId: db 255 ; on app header must be always 255 (will be given an id by the OS at app load) 7 | .windowState: db WINDOW_STATE.RESTORED 8 | .x: db 2 9 | .y: db 2 10 | .width: db 14 11 | .height: db 15 12 | .minWidth: db 14 13 | .minHeight: db 15 14 | 15 | .windowTitle: 16 | db TILE_FONT_REVERSED_LOWERCASE_T 17 | db TILE_FONT_REVERSED_LOWERCASE_E 18 | db TILE_FONT_REVERSED_LOWERCASE_T 19 | db TILE_FONT_REVERSED_LOWERCASE_R 20 | db TILE_FONT_REVERSED_LOWERCASE_A 21 | db 0 ; end of string ; TODO 22 | db 0 23 | db 0 24 | db 0 25 | db 0 26 | db 0 27 | db 0 28 | db 0 29 | db 0 30 | db 0 31 | db 0 32 | .taskbarTitle: 33 | db TILE_FONT_REVERSED_LOWERCASE_T 34 | db TILE_FONT_REVERSED_LOWERCASE_E 35 | db TILE_FONT_REVERSED_LOWERCASE_T 36 | db TILE_EMPTY_BLACK 37 | .iconTitle: 38 | db TILE_EMPTY 39 | db TILE_FONT_LOWERCASE_T 40 | db TILE_FONT_LOWERCASE_E 41 | db TILE_FONT_LOWERCASE_T 42 | db TILE_FONT_LOWERCASE_R 43 | db TILE_FONT_LOWERCASE_A 44 | db TILE_EMPTY 45 | 46 | .isFixedSize: db 0 47 | .vertScrollbarEnabled: db 0 48 | .vertScrollbarPosition: db 0 49 | 50 | 51 | .openAddr: dw Tetra_Open 52 | .workAddr: dw Tetra_Work 53 | .drawAddr: dw Tetra_Draw 54 | .clickAddr: dw Tetra_Click 55 | .getFocusAddr: dw Tetra_GetFocus 56 | .loseFocusAddr: dw Tetra_LoseFocus 57 | .closeAddr: dw Tetra_Close 58 | 59 | .iconAddr: dw Tetra_Icon 60 | 61 | .ramSize: dw 1024 ; RAM space reserved for variables of this app 62 | 63 | 64 | ; -------------------------------------------------- 65 | Tetra.StartProgramCode: 66 | 67 | Tetra_Open: 68 | INCLUDE "Apps/Tetra/Open.s" 69 | 70 | Tetra_Work: 71 | INCLUDE "Apps/Tetra/Work.s" 72 | 73 | Tetra_Draw: 74 | INCLUDE "Apps/Tetra/Draw.s" 75 | 76 | Tetra_Click: 77 | INCLUDE "Apps/Tetra/Click.s" 78 | 79 | Tetra_GetFocus: 80 | INCLUDE "Apps/Tetra/GetFocus.s" 81 | 82 | Tetra_LoseFocus: 83 | INCLUDE "Apps/Tetra/LoseFocus.s" 84 | 85 | Tetra_Close: 86 | INCLUDE "Apps/Tetra/Close.s" 87 | 88 | Tetra.EndProgramCode: ; this may be useful on future for code dinamically relocatable 89 | 90 | 91 | 92 | ; -------------------------------------------------- 93 | Tetra.StartProgramData: 94 | 95 | Tetra_Icon: 96 | INCLUDE "Apps/Tetra/Icon.s" 97 | 98 | Tetra_Data: 99 | INCLUDE "Apps/Tetra/Data.s" 100 | 101 | Tetra.EndProgramData: ; this may be useful on future for code dinamically relocatable 102 | 103 | -------------------------------------------------------------------------------- /Apps/Tetra/Header.s: -------------------------------------------------------------------------------- 1 | Tetra: 2 | 3 | ; fixed values for app initialization 4 | .Header: 5 | 6 | .processId: db 255 ; on app header must be always 255 (will be given an id by the OS at app load) 7 | .windowState: db WINDOW_STATE.RESTORED 8 | .x: db 2 9 | .y: db 2 10 | .width: db 14 11 | .height: db 22 12 | .minWidth: db 14 13 | .minHeight: db 22 14 | 15 | .windowTitle: 16 | db TILE_FONT_REVERSED_LOWERCASE_T 17 | db TILE_FONT_REVERSED_LOWERCASE_E 18 | db TILE_FONT_REVERSED_LOWERCASE_T 19 | db TILE_FONT_REVERSED_LOWERCASE_R 20 | db TILE_FONT_REVERSED_LOWERCASE_A 21 | db 0 ; end of string ; TODO 22 | db 0 23 | db 0 24 | db 0 25 | db 0 26 | db 0 27 | db 0 28 | db 0 29 | db 0 30 | db 0 31 | db 0 32 | .taskbarTitle: 33 | db TILE_FONT_REVERSED_LOWERCASE_T 34 | db TILE_FONT_REVERSED_LOWERCASE_E 35 | db TILE_FONT_REVERSED_LOWERCASE_T 36 | db TILE_FONT_REVERSED_LOWERCASE_R 37 | .iconTitle: 38 | db TILE_EMPTY 39 | db TILE_FONT_LOWERCASE_T 40 | db TILE_FONT_LOWERCASE_E 41 | db TILE_FONT_LOWERCASE_T 42 | db TILE_FONT_LOWERCASE_R 43 | db TILE_FONT_LOWERCASE_A 44 | db TILE_EMPTY 45 | 46 | .isFixedSize: db 0 47 | .vertScrollbarEnabled: db 0 48 | .vertScrollbarPosition: db 0 49 | 50 | 51 | .openAddr: dw Tetra_Open 52 | .workAddr: dw Tetra_Work 53 | .drawAddr: dw Tetra_Draw 54 | .clickAddr: dw Tetra_Click 55 | .getFocusAddr: dw Tetra_GetFocus 56 | .loseFocusAddr: dw Tetra_LoseFocus 57 | .closeAddr: dw Tetra_Close 58 | 59 | .iconAddr: dw Tetra_Icon 60 | 61 | .ramSize: dw 1024 ; RAM space reserved for variables of this app 62 | 63 | 64 | ; -------------------------------------------------- 65 | Tetra.StartProgramCode: 66 | 67 | Tetra_Open: 68 | INCLUDE "Apps/Tetra/Open.s" 69 | 70 | Tetra_Work: 71 | INCLUDE "Apps/Tetra/Work.s" 72 | 73 | Tetra_Draw: 74 | INCLUDE "Apps/Tetra/Draw.s" 75 | 76 | Tetra_Click: 77 | INCLUDE "Apps/Tetra/Click.s" 78 | 79 | Tetra_GetFocus: 80 | INCLUDE "Apps/Tetra/GetFocus.s" 81 | 82 | Tetra_LoseFocus: 83 | INCLUDE "Apps/Tetra/LoseFocus.s" 84 | 85 | Tetra_Close: 86 | INCLUDE "Apps/Tetra/Close.s" 87 | 88 | Tetra.EndProgramCode: ; this may be useful on future for code dinamically relocatable 89 | 90 | 91 | 92 | ; -------------------------------------------------- 93 | Tetra.StartProgramData: 94 | 95 | Tetra_Icon: 96 | INCLUDE "Apps/Tetra/Icon.s" 97 | 98 | Tetra_Data: 99 | INCLUDE "Apps/Tetra/Data.s" 100 | 101 | Tetra.EndProgramData: ; this may be useful on future for code dinamically relocatable 102 | 103 | -------------------------------------------------------------------------------- /Apps/Calc/Header.s: -------------------------------------------------------------------------------- 1 | Calc: 2 | 3 | ; fixed values for app initialization 4 | .Header: 5 | 6 | .processId: db 255 ; on app header must be always 255 (will be given an id by the OS at app load) 7 | .windowState: db WINDOW_STATE.RESTORED 8 | .x: db 8 + 13 9 | .y: db 8 10 | .width: db 14 11 | .height: db 18 12 | .minWidth: db 14 13 | .minHeight: db 18 14 | 15 | .windowTitle: 16 | db TILE_FONT_REVERSED_LOWERCASE_A + 2 ; 'c' 17 | db TILE_FONT_REVERSED_LOWERCASE_A + 0 ; 'a' 18 | db TILE_FONT_REVERSED_LOWERCASE_A + 11 ; 'l' 19 | db TILE_FONT_REVERSED_LOWERCASE_A + 2 ; 'c' 20 | db 0 ; end of string 21 | db 0 22 | db 0 23 | db 0 24 | db 0 25 | db 0 26 | db 0 27 | db 0 28 | db 0 29 | db 0 30 | db 0 31 | db 0 32 | .taskbarTitle: 33 | db TILE_FONT_REVERSED_LOWERCASE_A + 2 ; 'c' 34 | db TILE_FONT_REVERSED_LOWERCASE_A + 0 ; 'a' 35 | db TILE_FONT_REVERSED_LOWERCASE_A + 11 ; 'l' 36 | db TILE_FONT_REVERSED_LOWERCASE_A + 2 ; 'c' 37 | .iconTitle: 38 | db TILE_EMPTY 39 | db TILE_FONT_LOWERCASE_A + 2 ; 'c' 40 | db TILE_FONT_LOWERCASE_A + 0 ; 'a' 41 | db TILE_FONT_LOWERCASE_A + 11 ; 'l' 42 | db TILE_FONT_LOWERCASE_A + 2 ; 'c' 43 | db TILE_EMPTY 44 | db TILE_EMPTY 45 | 46 | .isFixedSize: db 0 47 | .vertScrollbarEnabled: db 0 48 | .vertScrollbarPosition: db 0 49 | 50 | 51 | .openAddr: dw Calc_Open 52 | .workAddr: dw Calc_Work 53 | .drawAddr: dw Calc_Draw 54 | .clickAddr: dw Calc_Click 55 | .getFocusAddr: dw Calc_GetFocus 56 | .loseFocusAddr: dw Calc_LoseFocus 57 | .closeAddr: dw Calc_Close 58 | 59 | .iconAddr: dw Calc_Icon 60 | 61 | .ramSize: dw 1024 ; RAM space reserved for variables of this app 62 | 63 | 64 | ; ------------------------------------------------- 65 | Calc.StartProgramCode: 66 | 67 | Calc_Open: 68 | INCLUDE "Apps/Calc/Open.s" 69 | 70 | Calc_Work: 71 | INCLUDE "Apps/Calc/Work.s" 72 | 73 | Calc_Draw: 74 | INCLUDE "Apps/Calc/Draw.s" 75 | 76 | Calc_Click: 77 | INCLUDE "Apps/Calc/Click.s" 78 | 79 | Calc_GetFocus: 80 | INCLUDE "Apps/Calc/GetFocus.s" 81 | 82 | Calc_LoseFocus: 83 | INCLUDE "Apps/Calc/LoseFocus.s" 84 | 85 | Calc_Close: 86 | INCLUDE "Apps/Calc/Close.s" 87 | 88 | Calc.EndProgramCode: ; this may be useful on future for code dinamically relocatable 89 | 90 | 91 | 92 | ; -------------------------------------------------- 93 | Calc.StartProgramData: 94 | 95 | Calc_Icon: 96 | INCLUDE "Apps/Calc/Icon.s" 97 | 98 | Calc_Data: 99 | INCLUDE "Apps/Calc/Data.s" 100 | 101 | Calc.EndProgramData: ; this may be useful on future for code dinamically relocatable 102 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "assembly", 8 | "type": "shell", 9 | "command": "C:\\Users\\Public\\msx\\tniasm\\tniasm.exe", //"C:\\Program Files\\tniasm045\\tniasm.exe", 10 | "args": [ 11 | { 12 | "value": "System\\Main.s", 13 | //"value": "${file}", 14 | "quoting": "strong" 15 | } 16 | ], 17 | "problemMatcher": [], 18 | "group": "build", 19 | "presentation": { 20 | "reveal": "always" 21 | } 22 | }, 23 | { 24 | "command": "C:\\Users\\Public\\msx\\openmsx\\openmsx.exe", //"C:\\Program Files\\openMSX\\openmsx.exe", 25 | "args": [ 26 | { 27 | "value": "${workspaceFolder}\\msx-windows.rom", 28 | //"value": "${fileBasenameNoExtension}.rom", 29 | "quoting": "strong" 30 | }, 31 | { 32 | // When changing this, it's necessary to first save this file before build, it will not work with 33 | // the "auto save all unsaved files before build" feature of VS Code (it executes this file before save) 34 | 35 | "value": "-machine Gradiente_Expert_GPC-1", // MSX 1 36 | //"value": "-machine Yamaha_CX11", // MSX 1 with V9938 37 | //"value": "-machine Sony_HB-F1XD", // MSX 2 38 | // "value": "-machine Sony_HB-F1XDJ", // MSX 2+ 39 | //"value": "-machine Panasonic_FS-A1WSX", // MSX 2+ with turbo 40 | //"value": "-machine Panasonic_FS-A1GT", // MSX Turbo R 41 | 42 | "quoting": "weak" 43 | }, 44 | // { 45 | // "value": "-romtype ASCII16", 46 | // "quoting": "weak" 47 | // }, 48 | // { 49 | // //"value": "-script ${workspaceFolder}\\msx-wings_debug.tcl", 50 | // "value": "-script ${workspaceFolder}\\profiler.tcl", 51 | // "quoting": "weak" 52 | // }, 53 | { 54 | "value": "-script ${workspaceFolder}\\msx-windows_debug.tcl", 55 | "quoting": "weak" 56 | }, 57 | { 58 | "value": "-script ${workspaceFolder}\\add_mouse.tcl", 59 | "quoting": "weak" 60 | } 61 | ], 62 | "label": "run openmsx", 63 | "type": "shell", 64 | "dependsOn": [ 65 | "assembly" 66 | ], 67 | "problemMatcher": [], 68 | "group": { 69 | "kind": "build", 70 | "isDefault": true 71 | }, 72 | "presentation": { 73 | "reveal": "always" 74 | } 75 | } 76 | ] 77 | } -------------------------------------------------------------------------------- /Apps/Paint/Header.s: -------------------------------------------------------------------------------- 1 | Paint: 2 | 3 | ; fixed values for app initialization 4 | .Header: 5 | 6 | .processId: db 255 ; on app header must be always 255 (will be given an id by the OS at app load) 7 | .windowState: db WINDOW_STATE.RESTORED 8 | .x: db 8 - 3 9 | .y: db 4 10 | .width: db 14 11 | .height: db 8 12 | .minWidth: db 12 13 | .minHeight: db 6 14 | 15 | .windowTitle: 16 | db TILE_FONT_REVERSED_LOWERCASE_A + 15 ; 'p' 17 | db TILE_FONT_REVERSED_LOWERCASE_A + 0 ; 'a' 18 | db TILE_FONT_REVERSED_LOWERCASE_A + 8 ; 'i' 19 | db TILE_FONT_REVERSED_LOWERCASE_A + 13 ; 'n' 20 | db TILE_FONT_REVERSED_LOWERCASE_A + 19 ; 't' 21 | db 0 ; end of string 22 | db 0 23 | db 0 24 | db 0 25 | db 0 26 | db 0 27 | db 0 28 | db 0 29 | db 0 30 | db 0 31 | db 0 32 | .taskbarTitle: 33 | db TILE_FONT_REVERSED_LOWERCASE_A + 15 ; 'p' 34 | db TILE_FONT_REVERSED_LOWERCASE_A + 13 ; 'n' 35 | db TILE_FONT_REVERSED_LOWERCASE_A + 19 ; 't' 36 | db TILE_EMPTY_BLACK 37 | .iconTitle: 38 | db TILE_EMPTY 39 | db TILE_FONT_LOWERCASE_A + 15 ; 'p' 40 | db TILE_FONT_LOWERCASE_A + 0 ; 'a' 41 | db TILE_FONT_LOWERCASE_A + 8 ; 'i' 42 | db TILE_FONT_LOWERCASE_A + 13 ; 'n' 43 | db TILE_FONT_LOWERCASE_A + 19 ; 't' 44 | db TILE_EMPTY 45 | 46 | .isFixedSize: db 0 47 | .vertScrollbarEnabled: db 0 48 | .vertScrollbarPosition: db 0 49 | 50 | 51 | .openAddr: dw Paint_Open 52 | .workAddr: dw Paint_Work 53 | .drawAddr: dw Paint_Draw 54 | .clickAddr: dw Paint_Click 55 | .getFocusAddr: dw Paint_GetFocus 56 | .loseFocusAddr: dw Paint_LoseFocus 57 | .closeAddr: dw Paint_Close 58 | 59 | .iconAddr: dw Paint_Icon 60 | 61 | .ramSize: dw 1024 ; RAM space reserved for variables of this app 62 | 63 | 64 | ; -------------------------------------------------- 65 | Paint.StartProgramCode: 66 | 67 | Paint_Open: 68 | INCLUDE "Apps/Paint/Open.s" 69 | 70 | Paint_Work: 71 | INCLUDE "Apps/Paint/Work.s" 72 | 73 | Paint_Draw: 74 | INCLUDE "Apps/Paint/Draw.s" 75 | 76 | Paint_Click: 77 | INCLUDE "Apps/Paint/Click.s" 78 | 79 | Paint_GetFocus: 80 | INCLUDE "Apps/Paint/GetFocus.s" 81 | 82 | Paint_LoseFocus: 83 | INCLUDE "Apps/Paint/LoseFocus.s" 84 | 85 | Paint_Close: 86 | INCLUDE "Apps/Paint/Close.s" 87 | 88 | Paint.EndProgramCode: ; this may be useful on future for code dinamically relocatable 89 | 90 | 91 | 92 | ; -------------------------------------------------- 93 | Paint.StartProgramData: 94 | 95 | Paint_Icon: 96 | INCLUDE "Apps/Paint/Icon.s" 97 | 98 | Paint_Data: 99 | INCLUDE "Apps/Paint/Data.s" 100 | 101 | Paint.EndProgramData: ; this may be useful on future for code dinamically relocatable 102 | 103 | -------------------------------------------------------------------------------- /Apps/Notepad/Draw.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; --- draw vertical scrollbar 6 | call GET_WINDOW_NAMTBL_LAST_USEFUL_COLUMN 7 | 8 | call BIOS_SETWRT 9 | ld c, PORT_0 10 | ld a, TILE_ARROW_UP 11 | out (c), a 12 | 13 | call GET_WINDOW_USEFUL_HEIGHT 14 | sub 3 ; sub 1 because of the up arrow, sub 1 because of the down arrow 15 | ld b, a 16 | ld de, 32 17 | add hl, de ; next line 18 | .loop_1: 19 | call BIOS_SETWRT 20 | ld a, TILE_DOTS_VERTICAL 21 | out (c), a 22 | add hl, de ; next line 23 | djnz .loop_1 24 | 25 | call BIOS_SETWRT 26 | ld c, PORT_0 27 | ld a, TILE_ARROW_DOWN 28 | out (c), a 29 | 30 | ; ------ 31 | 32 | ; --- draw horizontal scrollbar 33 | ; call GET_WINDOW_NAMTBL_LAST_USEFUL_COLUMN 34 | call GET_USEFUL_WINDOW_BASE_NAMTBL 35 | push hl 36 | call GET_WINDOW_USEFUL_HEIGHT 37 | sub 1 38 | ld h, 0 39 | ld l, a 40 | add hl, hl ; mult by 32 to convert from columns to lines 41 | add hl, hl 42 | add hl, hl 43 | add hl, hl 44 | add hl, hl 45 | ex de, hl 46 | pop hl 47 | add hl, de 48 | 49 | 50 | call BIOS_SETWRT 51 | ld c, PORT_0 52 | ld a, TILE_ARROW_LEFT 53 | out (c), a 54 | 55 | call GET_WINDOW_USEFUL_WIDTH 56 | sub 3 ; decrease 2 for left and right arrows, plus 1 57 | ld b, a 58 | .loop_2: 59 | ld a, TILE_DOTS_HORIZONTAL 60 | out (c), a 61 | djnz .loop_2 62 | 63 | ld a, TILE_ARROW_RIGHT 64 | out (c), a 65 | 66 | ; -------------------------------- Draw text 67 | 68 | 69 | call GET_USEFUL_WINDOW_BASE_NAMTBL 70 | 71 | call BIOS_SETWRT 72 | 73 | ; ld de, TEST_NOTEPAD_DRAW_EVENT_STRING 74 | ; call _DRAW_STRING 75 | 76 | 77 | ; ; get RAM variables area of this process 78 | ; ld l, (ix + PROCESS_STRUCT_IX.ramStartAddr) 79 | ; ld h, (ix + PROCESS_STRUCT_IX.ramStartAddr + 1) 80 | 81 | ; push hl ; IY = HL 82 | ; pop iy 83 | 84 | ; ld c, PORT_0 85 | 86 | ld d, 0 ; counter for line width 87 | push iy 88 | .loop: 89 | ld a, (iy + NOTEPAD_VARS.TEXT_START) 90 | cp TEXT_END_OF_FILE 91 | jp z, .endLoop 92 | 93 | ld e, a 94 | 95 | ld a, (ix + PROCESS_STRUCT_IX.windowState) 96 | cp WINDOW_STATE.RESTORED 97 | jp z, .isRestored 98 | 99 | ; check window width for maximized window 100 | ld b, 32 101 | jp .checkWidth 102 | 103 | .isRestored: 104 | ; check window width for restored window 105 | ld a, (ix + PROCESS_STRUCT_IX.width) 106 | sub 3 107 | ld b, a 108 | 109 | .checkWidth: 110 | ld a, d 111 | ; A = line width, B = window width 112 | cp b 113 | jp nc, .ignore 114 | 115 | ld a, e 116 | out (PORT_0), a 117 | 118 | .ignore: 119 | 120 | inc d 121 | inc iy 122 | jp .loop 123 | 124 | .endLoop: 125 | pop iy 126 | 127 | ret 128 | -------------------------------------------------------------------------------- /Apps/Settings/Header.s: -------------------------------------------------------------------------------- 1 | Settings: 2 | 3 | ; fixed values for app initialization 4 | .Header: 5 | 6 | .processId: db 255 ; on app header must be always 255 (will be given an id by the OS at app load) 7 | .windowState: db WINDOW_STATE.RESTORED 8 | .x: db 2 9 | .y: db 2 10 | .width: db 20 11 | .height: db 16 12 | .minWidth: db 20 13 | .minHeight: db 6 14 | 15 | .windowTitle: 16 | db TILE_FONT_REVERSED_LOWERCASE_S 17 | db TILE_FONT_REVERSED_LOWERCASE_E 18 | db TILE_FONT_REVERSED_LOWERCASE_T 19 | db TILE_FONT_REVERSED_LOWERCASE_T 20 | db TILE_FONT_REVERSED_LOWERCASE_I 21 | db TILE_FONT_REVERSED_LOWERCASE_N 22 | db TILE_FONT_REVERSED_LOWERCASE_G 23 | db TILE_FONT_REVERSED_LOWERCASE_S 24 | db 0 ; end of string ; TODO 25 | db 0 26 | db 0 27 | db 0 28 | db 0 29 | db 0 30 | db 0 31 | db 0 32 | .taskbarTitle: 33 | db TILE_FONT_REVERSED_LOWERCASE_S 34 | db TILE_FONT_REVERSED_LOWERCASE_E 35 | db TILE_FONT_REVERSED_LOWERCASE_T 36 | db TILE_EMPTY_BLACK 37 | .iconTitle: 38 | db TILE_FONT_LOWERCASE_S 39 | db TILE_FONT_LOWERCASE_E 40 | db TILE_FONT_LOWERCASE_T 41 | db TILE_FONT_LOWERCASE_T 42 | db TILE_FONT_LOWERCASE_I 43 | db TILE_FONT_LOWERCASE_N 44 | db TILE_FONT_LOWERCASE_G 45 | 46 | .isFixedSize: db 0 47 | .vertScrollbarEnabled: db 0 48 | .vertScrollbarPosition: db 0 49 | 50 | 51 | .openAddr: dw Settings_Open 52 | .workAddr: dw Settings_Work 53 | .drawAddr: dw Settings_Draw 54 | .clickAddr: dw Settings_Click 55 | .getFocusAddr: dw Settings_GetFocus 56 | .loseFocusAddr: dw Settings_LoseFocus 57 | .closeAddr: dw Settings_Close 58 | 59 | .iconAddr: dw Settings_Icon 60 | 61 | .ramSize: dw 1024 ; RAM space reserved for variables of this app 62 | 63 | 64 | ; -------------------------------------------------- 65 | Settings.StartProgramCode: 66 | 67 | Settings_Open: 68 | INCLUDE "Apps/Settings/Open.s" 69 | 70 | Settings_Work: 71 | INCLUDE "Apps/Settings/Work.s" 72 | 73 | Settings_Draw: 74 | INCLUDE "Apps/Settings/Draw.s" 75 | 76 | Settings_Click: 77 | INCLUDE "Apps/Settings/Click.s" 78 | 79 | Settings_GetFocus: 80 | INCLUDE "Apps/Settings/GetFocus.s" 81 | 82 | Settings_LoseFocus: 83 | INCLUDE "Apps/Settings/LoseFocus.s" 84 | 85 | Settings_Close: 86 | INCLUDE "Apps/Settings/Close.s" 87 | 88 | Settings.EndProgramCode: ; this may be useful on future for code dinamically relocatable 89 | 90 | 91 | 92 | ; -------------------------------------------------- 93 | Settings.StartProgramData: 94 | 95 | Settings_Icon: 96 | INCLUDE "Apps/Settings/Icon.s" 97 | 98 | Settings_Data: 99 | INCLUDE "Apps/Settings/Data.s" 100 | 101 | Settings.EndProgramData: ; this may be useful on future for code dinamically relocatable 102 | 103 | -------------------------------------------------------------------------------- /System/Main.s: -------------------------------------------------------------------------------- 1 | FNAME "msx-windows.rom" ; output file 2 | 3 | PageSize: equ 0x4000 ; 16kB 4 | 5 | ; Compilation address 6 | org 0x4000 7 | 8 | ROM_Start: 9 | 10 | INCLUDE "Include/RomHeader.s" 11 | INCLUDE "Include/MsxBios.s" 12 | INCLUDE "Include/MsxConstants.s" 13 | INCLUDE "Include/CommonRoutines.s" 14 | 15 | ; System 16 | System_Code_Start: 17 | INCLUDE "System/Constants.s" 18 | INCLUDE "System/Interrupt.s" 19 | INCLUDE "System/Init/Init.s" 20 | INCLUDE "System/Desktop/Desktop.s" 21 | INCLUDE "System/Window/Window.s" 22 | INCLUDE "System/Keyboard/Keyboard.s" 23 | INCLUDE "System/Mouse/Mouse.s" 24 | INCLUDE "System/Process/Process.s" 25 | INCLUDE "System/Time/Time.s" 26 | System_Code_Size: equ $ - System_Code_Start ; currently 5047 bytes 27 | 28 | 29 | ; Assets 30 | Assets_Start: 31 | ; INCLUDE "Fonts/Atari_Regular.s" 32 | INCLUDE "Graphics/Tiles.s" 33 | INCLUDE "Graphics/Sprites.s" 34 | Assets_Size: equ $ - Assets_Start ; currently 1656 bytes 35 | 36 | 37 | ; Apps 38 | Apps_Start: 39 | INCLUDE "Apps/Notepad/Header.s" 40 | INCLUDE "Apps/Calc/Header.s" 41 | INCLUDE "Apps/Paint/Header.s" 42 | INCLUDE "Apps/Settings/Header.s" 43 | INCLUDE "Apps/TicTacToe/Header.s" 44 | INCLUDE "Apps/Tetra/Header.s" 45 | Apps_Size: equ $ - Apps_Start ; currently 4080 bytes 46 | 47 | 48 | 49 | Execute: 50 | ; init interrupt mode and stack pointer (in case the ROM isn't the first thing to be loaded) 51 | di ; disable interrupts 52 | im 1 ; interrupt mode 1 53 | ld sp, (BIOS_HIMEM) ; init SP 54 | ei 55 | 56 | ; routines named in uppercase means they are OS routines (unless started by "BIOS_") 57 | ; _ on start means private routines (internal to the OS) while absence of underline means public routines (can be called by apps) 58 | 59 | call _INIT 60 | 61 | .OS_MainLoop: 62 | 63 | 64 | ; --- mouse events 65 | call _DRAW_MOUSE_CURSOR 66 | call _MOUSE_CLICK 67 | call _MOUSE_OVER 68 | 69 | 70 | call _READ_KEYBOARD 71 | 72 | 73 | ; ---------- work to be done once per second 74 | ld a, (OS.timeCounter) 75 | or a 76 | jp nz, .skip 77 | 78 | call _DRAW_TASKBAR_CLOCK 79 | 80 | .skip: 81 | ; ----------------------------------------- 82 | 83 | ; run current process "Work" event 84 | ld ix, (OS.currentProcessAddr) 85 | ld a, ixl 86 | or ixh 87 | jp z, .noCurrentProcess ; if (OS.currentProcessAddr == 0x0000) .noCurrentProcess 88 | 89 | ; get RAM variables area of this process 90 | ld l, (ix + PROCESS_STRUCT_IX.ramStartAddr) 91 | ld h, (ix + PROCESS_STRUCT_IX.ramStartAddr + 1) 92 | 93 | push hl ; IY = HL 94 | pop iy 95 | 96 | ld e, (ix + PROCESS_STRUCT_IX.workAddr) ; process.Work addr (low) 97 | ld d, (ix + PROCESS_STRUCT_IX.workAddr + 1) ; process.Work addr (high) 98 | call JP_DE 99 | .noCurrentProcess: 100 | 101 | jp .OS_MainLoop 102 | 103 | 104 | ; current ROM size: 11648 bytes (some things may be compressed, mainly tiles (2kb)) 105 | db "End ROM started at 0x4000" 106 | 107 | ROM_Size: equ $ - ROM_Start 108 | 109 | ds PageSize - ($ - 0x4000), 255 ; Fill the unused area with 0xff 110 | 111 | 112 | 113 | ; RAM 114 | org 0xc000, 0xe5ff 115 | 116 | INCLUDE "System/Ram.s" 117 | -------------------------------------------------------------------------------- /Apps/Settings/Icon.s: -------------------------------------------------------------------------------- 1 | ;----- 2 | DB 00000000b 3 | DB 00000000b 4 | DB 00000000b 5 | DB 00000000b 6 | DB 00000110b 7 | DB 00001001b 8 | DB 00001000b 9 | DB 00000100b 10 | 11 | DB 00000100b 12 | DB 00111001b 13 | DB 00100000b 14 | DB 00101010b 15 | DB 00110100b 16 | DB 00011000b 17 | DB 00001001b 18 | DB 00001010b 19 | 20 | DB 00001010b 21 | DB 00001011b 22 | DB 00001110b 23 | DB 00000000b 24 | DB 00000000b 25 | DB 00000000b 26 | DB 00000000b 27 | DB 00000000b 28 | 29 | ; DB 00000000 b 30 | ; DB 01110000 b 31 | ; DB 01110000 b 32 | ; DB 01110000 b 33 | ; DB 00000000 b 34 | ; DB 01110111 b 35 | ; DB 01110111 b 36 | ; DB 01110111 b 37 | 38 | ; DB 00000000 b 39 | ; DB 01110000 b 40 | ; DB 01110000 b 41 | ; DB 01110000 b 42 | ; DB 00000000 b 43 | ; DB 00000000 b 44 | ; DB 00000000 b 45 | ; DB 00000000 b 46 | 47 | ; DB 11111111 b 48 | ; DB 10001111 b 49 | ; DB 10001111 b 50 | ; DB 10001111 b 51 | ; DB 11111111 b 52 | ; DB 10001000 b 53 | ; DB 10001000 b 54 | ; DB 10001000 b 55 | 56 | ;----- 57 | 58 | DB 00000000b 59 | DB 00000000b 60 | DB 00111100b 61 | DB 01000010b 62 | DB 01111110b 63 | DB 11001011b 64 | DB 01000110b 65 | DB 01001010b 66 | DB 11000111b 67 | DB 01001010b 68 | DB 11000111b 69 | DB 01111110b 70 | DB 00000000b 71 | DB 11100111b 72 | DB 00100100b 73 | DB 00100100b 74 | 75 | DB 11100111b 76 | DB 00100100b 77 | DB 00100100b 78 | DB 00111100b 79 | DB 00000000b 80 | DB 00000000b 81 | DB 00000000b 82 | DB 00000000b 83 | 84 | ; DB 00000000b 85 | ; DB 11110000b 86 | ; DB 00001100b 87 | ; DB 11000110b 88 | ; DB 11100011b 89 | ; DB 11100001b 90 | ; DB 11000001b 91 | ; DB 00000000b 92 | 93 | ; DB 00000011b 94 | ; DB 00000100b 95 | ; DB 10001001b 96 | ; DB 00001010b 97 | ; DB 00000101b 98 | ; DB 10000011b 99 | ; DB 10000000b 100 | ; DB 11000011b 101 | 102 | ; DB 11001111b 103 | ; DB 11001111b 104 | ; DB 00000111b 105 | ; DB 00000000b 106 | ; DB 11111111b 107 | ; DB 11111111b 108 | ; DB 00000000b 109 | ; DB 00000000b 110 | ;----- 111 | 112 | DB 00000000b 113 | DB 00000000b 114 | DB 00000000b 115 | DB 00000000b 116 | 117 | DB 01100000b 118 | DB 10010000b 119 | DB 00010000b 120 | DB 00100000b 121 | 122 | DB 00100000b 123 | DB 10011000b 124 | DB 00000100b 125 | DB 01010100b 126 | 127 | DB 00101100b 128 | DB 10011000b 129 | DB 01010000b 130 | DB 01110000b 131 | 132 | DB 01110000b 133 | DB 11110000b 134 | DB 01100000b 135 | DB 00000000b 136 | 137 | DB 00000000b 138 | DB 00000000b 139 | DB 00000000b 140 | DB 00000000b 141 | 142 | ; DB 00000000b 143 | ; DB 00000100b 144 | ; DB 00000110b 145 | ; DB 00000110b 146 | ; DB 00001010b 147 | ; DB 00010110b 148 | ; DB 10011110b 149 | ; DB 10101100b 150 | 151 | ; DB 11010000b 152 | ; DB 11100000b 153 | ; DB 01110000b 154 | ; DB 11011000b 155 | ; DB 01001100b 156 | ; DB 10001100b 157 | ; DB 00001100b 158 | ; DB 00001100b 159 | 160 | ; DB 10011100b 161 | ; DB 00111000b 162 | ; DB 01110000b 163 | ; DB 11100000b 164 | ; DB 11000000b 165 | ; DB 10000000b 166 | ; DB 00000000b 167 | ; DB 00000000b 168 | 169 | ;----- 170 | -------------------------------------------------------------------------------- /Apps/TicTacToe/Header.s: -------------------------------------------------------------------------------- 1 | TicTacToe: 2 | 3 | ; fixed values for app initialization 4 | .Header: 5 | 6 | .processId: db 255 ; on app header must be always 255 (will be given an id by the OS at app load) 7 | .windowState: db WINDOW_STATE.RESTORED 8 | .x: db 2 9 | .y: db 2 10 | .width: db 14 11 | .height: db 15 12 | .minWidth: db 14 13 | .minHeight: db 15 14 | 15 | .windowTitle: 16 | db TILE_FONT_REVERSED_LOWERCASE_T 17 | db TILE_FONT_REVERSED_LOWERCASE_I 18 | db TILE_FONT_REVERSED_LOWERCASE_C 19 | db TILE_FONT_REVERSED_LOWERCASE_T 20 | db TILE_FONT_REVERSED_LOWERCASE_A 21 | db TILE_FONT_REVERSED_LOWERCASE_C 22 | db TILE_FONT_REVERSED_LOWERCASE_T 23 | db TILE_FONT_REVERSED_LOWERCASE_O 24 | db TILE_FONT_REVERSED_LOWERCASE_E 25 | db 0 ; end of string ; TODO 26 | db 0 27 | db 0 28 | db 0 29 | db 0 30 | db 0 31 | db 0 32 | .taskbarTitle: 33 | db TILE_FONT_REVERSED_LOWERCASE_T 34 | db TILE_FONT_REVERSED_LOWERCASE_I 35 | db TILE_FONT_REVERSED_LOWERCASE_C 36 | db TILE_EMPTY_BLACK 37 | .iconTitle: 38 | db TILE_FONT_LOWERCASE_T 39 | db TILE_FONT_LOWERCASE_I 40 | db TILE_FONT_LOWERCASE_C 41 | db TILE_EMPTY 42 | db TILE_FONT_LOWERCASE_T 43 | db TILE_FONT_LOWERCASE_A 44 | db TILE_FONT_LOWERCASE_C 45 | 46 | .isFixedSize: db 0 47 | .vertScrollbarEnabled: db 0 48 | .vertScrollbarPosition: db 0 49 | 50 | 51 | .openAddr: dw TicTacToe_Open 52 | .workAddr: dw TicTacToe_Work 53 | .drawAddr: dw TicTacToe_Draw 54 | .clickAddr: dw TicTacToe_Click 55 | .getFocusAddr: dw TicTacToe_GetFocus 56 | .loseFocusAddr: dw TicTacToe_LoseFocus 57 | .closeAddr: dw TicTacToe_Close 58 | 59 | .iconAddr: dw TicTacToe_Icon 60 | 61 | .ramSize: dw 1024 ; RAM space reserved for variables of this app 62 | 63 | 64 | ; -------------------------------------------------- 65 | TicTacToe.StartProgramCode: 66 | 67 | TicTacToe_Open: 68 | INCLUDE "Apps/TicTacToe/Open.s" 69 | 70 | TicTacToe_Work: 71 | INCLUDE "Apps/TicTacToe/Work.s" 72 | 73 | TicTacToe_Draw: 74 | INCLUDE "Apps/TicTacToe/Draw.s" 75 | 76 | TicTacToe_Click: 77 | INCLUDE "Apps/TicTacToe/Click.s" 78 | 79 | TicTacToe_GetFocus: 80 | INCLUDE "Apps/TicTacToe/GetFocus.s" 81 | 82 | TicTacToe_LoseFocus: 83 | INCLUDE "Apps/TicTacToe/LoseFocus.s" 84 | 85 | TicTacToe_Close: 86 | INCLUDE "Apps/TicTacToe/Close.s" 87 | 88 | TicTacToe.EndProgramCode: ; this may be useful on future for code dinamically relocatable 89 | 90 | 91 | 92 | ; -------------------------------------------------- 93 | TicTacToe.StartProgramData: 94 | 95 | TicTacToe_Icon: 96 | INCLUDE "Apps/TicTacToe/Icon.s" 97 | 98 | TicTacToe_Data: 99 | INCLUDE "Apps/TicTacToe/Data.s" 100 | 101 | TicTacToe.EndProgramData: ; this may be useful on future for code dinamically relocatable 102 | 103 | -------------------------------------------------------------------------------- /System/Interrupt.s: -------------------------------------------------------------------------------- 1 | _INIT_INTERRUPT: 2 | 3 | ; Setup interrupt hook 4 | xor a 5 | ld (os.interruptBusy), a 6 | 7 | ld hl, .storeOldInterruptHook_init 8 | ld de, os.storeOldInterruptHook 9 | ld bc, 6 10 | ldir 11 | 12 | ld hl, BIOS_H_TIMI 13 | ld de, os.storeOldInterruptHook 14 | ld bc, 5 15 | ldir 16 | 17 | ld hl, INTERRUPT 18 | ld de, BIOS_H_TIMI 19 | ld bc, 3 20 | ldir 21 | 22 | ret 23 | 24 | 25 | 26 | .storeOldInterruptHook_init: 27 | db 0, 0, 0, 0, 0 28 | db 0xc9 ; opcode for RET 29 | 30 | INTERRUPT: 31 | ; This will be copied to interrupt hook 32 | jp HANDLER 33 | 34 | HANDLER: 35 | ; This is actual interrupt handler routine 36 | ld a, (os.interruptBusy) 37 | and a 38 | ret nz 39 | ld a, 255 40 | ld (os.interruptBusy), a 41 | 42 | ; update system time 43 | call _UPDATE_SYSTEM_TIME 44 | 45 | ; OS.ticksSinceLastInput ++ 46 | ld hl, (OS.ticksSinceLastInput) 47 | inc hl 48 | ld (OS.ticksSinceLastInput), hl 49 | 50 | ; ; if (OS.ticksSinceLastInput == 3600) .triggerScreenSaver 51 | ; ld de, 3600 ; 60 seconds (on NTSC machines...) 52 | ; call BIOS_DCOMPR ; Compare Contents Of HL & DE, Set Z-Flag IF (HL == DE), Set CY-Flag IF (HL < DE) 53 | ; call z, .triggerScreenSaver 54 | 55 | ; ---------------- read mouse ------------ 56 | ; ld de, 0x1310 ; mouse on joyport 1 57 | ; ;ld de, 0x6C20 ; mouse on joyport 2 58 | ld de, MOUSE_PORT 59 | call GTMOUS 60 | ; if (H==255 && H==L) noMouse 61 | ld a, h 62 | cp 255 63 | jp nz, .skip 64 | cp l 65 | call z, .noMouse 66 | 67 | .skip: 68 | 69 | ; update mouse buttons state 70 | ld a, ixh 71 | ld (OS.mouseButton_1), a 72 | ld a, ixl 73 | ld (OS.mouseButton_2), a 74 | 75 | 76 | ; TODO: evaluate the possibility of saving mouse deltas and button states to OS vars and 77 | ; doing below processing outside interrupt (to keep interrupt as quick as possible) 78 | 79 | 80 | ; invert delta x 81 | ld a, h 82 | neg 83 | ld h, a 84 | 85 | ; invert delta y 86 | ld a, l 87 | neg 88 | ld l, a 89 | 90 | ; reset OS.ticksSinceLastInput if mouse moved or button clicked 91 | xor a 92 | or ixh ; mouse button 1 93 | or ixl ; mouse button 2 94 | or h ; mouse delta x 95 | or l ; mouse delta y 96 | jp z, .skip_1 97 | ld de, 0 98 | ld (OS.ticksSinceLastInput), de 99 | .skip_1: 100 | 101 | ld e, h ; delta X 102 | ld d, l ; delta Y 103 | ld a, (os.mouseX) 104 | ld l, a ; current X 105 | ld a, (os.mouseY) 106 | ld h, a ; current Y 107 | call CLIPADD 108 | 109 | ld a, l 110 | ld (os.mouseX), a 111 | ld (os.mouseX_1), a 112 | ld a, h 113 | ld (os.mouseY), a 114 | ld (OS.mouseY_1), a 115 | 116 | xor a 117 | ld (os.interruptBusy), a 118 | 119 | jp os.storeOldInterruptHook 120 | 121 | ; TODO: show alert message "No mouse detected" 122 | .noMouse: 123 | ; call BIOS_BEEP 124 | ret 125 | 126 | ; .triggerScreenSaver: 127 | ; ld hl, NAMTBL 128 | ; call BIOS_SETWRT 129 | ; ld a, TILE_FONT_NUMBERS_0 + 0 130 | ; out (PORT_0), a 131 | 132 | ; jp $ -------------------------------------------------------------------------------- /Apps/TicTacToe/Data.s: -------------------------------------------------------------------------------- 1 | 2 | .PLAYFIELD_TILES: 3 | 4 | db TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY 5 | db TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY 6 | 7 | db TILE_EMPTY, TILE_EMPTY, TILE_LINE_VERTICAL, TILE_EMPTY, TILE_EMPTY, TILE_LINE_VERTICAL, TILE_EMPTY, TILE_EMPTY 8 | db TILE_EMPTY, TILE_EMPTY, TILE_LINE_VERTICAL, TILE_EMPTY, TILE_EMPTY, TILE_LINE_VERTICAL, TILE_EMPTY, TILE_EMPTY 9 | 10 | db TILE_LINE_HORIZONTAL, TILE_LINE_HORIZONTAL, TILE_LINE_CROSS, TILE_LINE_HORIZONTAL, TILE_LINE_HORIZONTAL, TILE_LINE_CROSS, TILE_LINE_HORIZONTAL, TILE_LINE_HORIZONTAL 11 | 12 | db TILE_EMPTY, TILE_EMPTY, TILE_LINE_VERTICAL, TILE_EMPTY, TILE_EMPTY, TILE_LINE_VERTICAL, TILE_EMPTY, TILE_EMPTY 13 | db TILE_EMPTY, TILE_EMPTY, TILE_LINE_VERTICAL, TILE_EMPTY, TILE_EMPTY, TILE_LINE_VERTICAL, TILE_EMPTY, TILE_EMPTY 14 | 15 | db TILE_LINE_HORIZONTAL, TILE_LINE_HORIZONTAL, TILE_LINE_CROSS, TILE_LINE_HORIZONTAL, TILE_LINE_HORIZONTAL, TILE_LINE_CROSS, TILE_LINE_HORIZONTAL, TILE_LINE_HORIZONTAL 16 | 17 | db TILE_EMPTY, TILE_EMPTY, TILE_LINE_VERTICAL, TILE_EMPTY, TILE_EMPTY, TILE_LINE_VERTICAL, TILE_EMPTY, TILE_EMPTY 18 | db TILE_EMPTY, TILE_EMPTY, TILE_LINE_VERTICAL, TILE_EMPTY, TILE_EMPTY, TILE_LINE_VERTICAL, TILE_EMPTY, TILE_EMPTY 19 | 20 | .TILE_X_pattern_0: ; top left 21 | db 11000000 b 22 | db 11100000 b 23 | db 01110000 b 24 | db 00111000 b 25 | db 00011100 b 26 | db 00001110 b 27 | db 00000111 b 28 | db 00000011 b 29 | 30 | .TILE_X_pattern_1: ; top right 31 | db 00000011 b 32 | db 00000111 b 33 | db 00001110 b 34 | db 00011100 b 35 | db 00111000 b 36 | db 01110000 b 37 | db 11100000 b 38 | db 11000000 b 39 | 40 | .TILE_X_pattern_2: ; bottom left 41 | db 00000011 b 42 | db 00000111 b 43 | db 00001110 b 44 | db 00011100 b 45 | db 00111000 b 46 | db 01110000 b 47 | db 11100000 b 48 | db 11000000 b 49 | 50 | .TILE_X_pattern_3: ; bottom right 51 | db 11000000 b 52 | db 11100000 b 53 | db 01110000 b 54 | db 00111000 b 55 | db 00011100 b 56 | db 00001110 b 57 | db 00000111 b 58 | db 00000011 b 59 | 60 | .TILE_X_colors: 61 | db 0x4f 62 | db 0x4f 63 | db 0x4f 64 | db 0x4f 65 | db 0x4f 66 | db 0x4f 67 | db 0x4f 68 | db 0x4f 69 | 70 | ; --- 71 | 72 | .TILE_O_pattern_0: 73 | db 00000011 b 74 | db 00001111 b 75 | db 00011100 b 76 | db 00110000 b 77 | db 01100000 b 78 | db 01100000 b 79 | db 11000000 b 80 | db 11000000 b 81 | 82 | .TILE_O_pattern_1: 83 | db 11000000 b 84 | db 11110000 b 85 | db 00111000 b 86 | db 00001100 b 87 | db 00000110 b 88 | db 00000110 b 89 | db 00000011 b 90 | db 00000011 b 91 | 92 | .TILE_O_pattern_2: 93 | db 11000000 b 94 | db 11000000 b 95 | db 01100000 b 96 | db 01100000 b 97 | db 00110000 b 98 | db 00011100 b 99 | db 00001111 b 100 | db 00000011 b 101 | 102 | .TILE_O_pattern_3: 103 | db 00000011 b 104 | db 00000011 b 105 | db 00000110 b 106 | db 00000110 b 107 | db 00001100 b 108 | db 00111000 b 109 | db 11110000 b 110 | db 11000000 b 111 | 112 | .TILE_O_colors: 113 | db 0x8f 114 | db 0x8f 115 | db 0x8f 116 | db 0x8f 117 | db 0x8f 118 | db 0x8f 119 | db 0x8f 120 | db 0x8f 121 | 122 | 123 | ; ------------------------- 124 | 125 | TICTACTOE_VARS: 126 | .PLAYFIELD: equ 0 ; 3 * 3 = 9 bytes 127 | .CURRENT_PLAYER: equ 9 128 | -------------------------------------------------------------------------------- /Apps/Notepad/Header.s: -------------------------------------------------------------------------------- 1 | Notepad: 2 | 3 | ; fixed values for app initialization 4 | .Header: 5 | 6 | .processId: db 255 ; on app header must be always 255 (will be given an id by the OS at app load) 7 | .windowState: db WINDOW_STATE.RESTORED 8 | .x: db 8 - 3 9 | .y: db 4 10 | .width: db 14 11 | .height: db 8 12 | .minWidth: db 12 13 | .minHeight: db 7 14 | 15 | .windowTitle: 16 | db TILE_FONT_REVERSED_LOWERCASE_A + 13 ; 'n' 17 | db TILE_FONT_REVERSED_LOWERCASE_A + 14 ; 'o' 18 | db TILE_FONT_REVERSED_LOWERCASE_A + 19 ; 't' 19 | db TILE_FONT_REVERSED_LOWERCASE_A + 4 ; 'e' 20 | db TILE_FONT_REVERSED_LOWERCASE_A + 15 ; 'p' 21 | db TILE_FONT_REVERSED_LOWERCASE_A + 0 ; 'a' 22 | db TILE_FONT_REVERSED_LOWERCASE_A + 3 ; 'd' 23 | db 0 ; end of string 24 | db 0 25 | db 0 26 | db 0 27 | db 0 28 | db 0 29 | db 0 30 | db 0 31 | db 0 32 | .taskbarTitle: 33 | db TILE_FONT_REVERSED_LOWERCASE_A + 13 ; 'n' 34 | db TILE_FONT_REVERSED_LOWERCASE_A + 14 ; 'o' 35 | db TILE_FONT_REVERSED_LOWERCASE_A + 19 ; 't' 36 | db TILE_FONT_REVERSED_LOWERCASE_A + 4 ; 'e' 37 | .iconTitle: 38 | db TILE_FONT_LOWERCASE_A + 13 ; 'n' 39 | db TILE_FONT_LOWERCASE_A + 14 ; 'o' 40 | db TILE_FONT_LOWERCASE_A + 19 ; 't' 41 | db TILE_FONT_LOWERCASE_A + 4 ; 'e' 42 | db TILE_FONT_LOWERCASE_A + 15 ; 'p' 43 | db TILE_FONT_LOWERCASE_A + 0 ; 'a' 44 | db TILE_FONT_LOWERCASE_A + 3 ; 'd' 45 | 46 | .isFixedSize: db 0 47 | .vertScrollbarEnabled: db 0 48 | .vertScrollbarPosition: db 0 49 | 50 | 51 | .openAddr: dw Notepad_Open 52 | .workAddr: dw Notepad_Work 53 | .drawAddr: dw Notepad_Draw 54 | .clickAddr: dw Notepad_Click 55 | .getFocusAddr: dw Notepad_GetFocus 56 | .loseFocusAddr: dw Notepad_LoseFocus 57 | .closeAddr: dw Notepad_Close 58 | 59 | .iconAddr: dw Notepad_Icon 60 | 61 | .ramSize: dw 1024 ; RAM space reserved for variables of this app 62 | 63 | 64 | ; -------------------------------------------------- 65 | Notepad.StartProgramCode: 66 | 67 | Notepad_Open: 68 | INCLUDE "Apps/Notepad/Open.s" 69 | 70 | Notepad_Work: 71 | INCLUDE "Apps/Notepad/Work.s" 72 | 73 | Notepad_Draw: 74 | INCLUDE "Apps/Notepad/Draw.s" 75 | 76 | Notepad_Click: 77 | INCLUDE "Apps/Notepad/Click.s" 78 | 79 | Notepad_GetFocus: 80 | INCLUDE "Apps/Notepad/GetFocus.s" 81 | 82 | Notepad_LoseFocus: 83 | INCLUDE "Apps/Notepad/LoseFocus.s" 84 | 85 | Notepad_Close: 86 | INCLUDE "Apps/Notepad/Close.s" 87 | 88 | Notepad.EndProgramCode: ; this may be useful on future for code dinamically relocatable 89 | 90 | 91 | 92 | ; -------------------------------------------------- 93 | Notepad.StartProgramData: 94 | 95 | Notepad_Icon: 96 | INCLUDE "Apps/Notepad/Icon.s" 97 | 98 | Notepad_Data: 99 | INCLUDE "Apps/Notepad/Data.s" 100 | 101 | Notepad.EndProgramData: ; this may be useful on future for code dinamically relocatable 102 | 103 | -------------------------------------------------------------------------------- /System/Init/InitRam.s: -------------------------------------------------------------------------------- 1 | _INIT_RAM: 2 | 3 | ; TODO: clear all ram up to the stack 4 | ; clear RAM 5 | xor a 6 | ld (RamStart), a 7 | ld hl, RamStart 8 | ld de, RamStart + 1 9 | ld bc, RamEnd - RamStart - 1 10 | ldir 11 | 12 | ; init process area (fill with 0xff) 13 | ld a, 0xff 14 | ld (OS.processes), a 15 | ld hl, OS.processes 16 | ld de, OS.processes + 1 17 | ld bc, OS.processes_size - 1 18 | ldir 19 | 20 | ; set next available process slot to the first one 21 | ld hl, OS.processes 22 | ld (OS.nextAvailableProcessAddr), hl 23 | 24 | ; set current process to 0x0000 (null) 25 | ld hl, 0 26 | ld (OS.currentProcessAddr), hl 27 | 28 | ; init mouse/cursor variables 29 | ld a, 128 - 8 30 | ld (OS.mouseY), a 31 | ld (OS.mouseY_1), a 32 | ld a, 96 - 8 33 | ld (OS.mouseX), a 34 | ld (OS.mouseX_1), a 35 | ld a, SPRITE_INDEX_CURSOR_0 36 | ld (OS.mousePattern), a 37 | ld a, SPRITE_INDEX_CURSOR_1 38 | ld (OS.mousePattern_1), a 39 | ld a, 1 ; black 40 | ld (OS.mouseColor), a 41 | ld a, 15 ; white 42 | ld (OS.mouseColor_1), a 43 | 44 | xor a 45 | ld (OS.mouseButton_1), a 46 | ld (OS.mouseButton_2), a 47 | ld (OS.oldMouseButton_1), a 48 | ld (OS.oldMouseButton_2), a 49 | ld (OS.isDoubleClick), a 50 | 51 | ld (OS.isDraggingWindow), a 52 | ld (OS.dragOffset_X), a 53 | ld (OS.dragOffset_Y), a 54 | ld (OS.isResizingWindow), a 55 | ld (OS.resizeWindowCorner_BottomRight_X_Min), a 56 | ld (OS.resizeWindowCorner_BottomRight_Y_Min), a 57 | 58 | ld hl, 0 59 | ld (OS.mouseLastClick_Jiffy), hl 60 | 61 | ; set window corners sprites vars 62 | ld a, SPRITE_INDEX_WINDOW_TOP_LEFT 63 | ld (OS.windowCorner_TopLeft_Pattern), a 64 | ld a, SPRITE_INDEX_WINDOW_BOTTOM_LEFT 65 | ld (OS.windowCorner_BottomLeft_Pattern), a 66 | ld a, SPRITE_INDEX_WINDOW_TOP_RIGHT 67 | ld (OS.windowCorner_TopRight_Pattern), a 68 | ld a, SPRITE_INDEX_WINDOW_BOTTOM_RIGHT 69 | ld (OS.windowCorner_BottomRight_Pattern), a 70 | 71 | ld a, 15 ; white 72 | ld (OS.windowCorner_TopLeft_Color), a 73 | ld (OS.windowCorner_BottomLeft_Color), a 74 | ld (OS.windowCorner_TopRight_Color), a 75 | ld (OS.windowCorner_BottomRight_Color), a 76 | 77 | ; init keyboard vars 78 | ld a, 1111 1111 b 79 | ld (OS.oldKeyboardMatrix + 0), a 80 | ld (OS.oldKeyboardMatrix + 1), a 81 | ld (OS.oldKeyboardMatrix + 2), a 82 | ld (OS.oldKeyboardMatrix + 3), a 83 | ld (OS.oldKeyboardMatrix + 4), a 84 | ld (OS.oldKeyboardMatrix + 5), a 85 | ld (OS.oldKeyboardMatrix + 6), a 86 | ld (OS.oldKeyboardMatrix + 7), a 87 | ld (OS.oldKeyboardMatrix + 8), a 88 | ld (OS.oldKeyboardMatrix + 9), a 89 | 90 | 91 | ; init video vars 92 | ld a, 0 93 | ld (OS.nextWindow_x), a 94 | ld a, 0 95 | ld (OS.nextWindow_y), a 96 | 97 | xor a 98 | ld (OS.mouseOver_Activated), a 99 | ld (OS.mouseOver_screenMappingValue), a 100 | ld (OS.mouseOver_tileToBeRestored), a 101 | ld hl, 0 102 | ld (OS.mouseOver_NAMTBL_addr), a 103 | 104 | 105 | 106 | call _INIT_SCREEN_MAPPING 107 | 108 | 109 | 110 | ret 111 | 112 | 113 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # msx-windows 2 | OS with graphic interface for MSX 1 3 | 4 | Proof of concept for the viability of a mouse oriented OS with GUI, as Windows 3.xx/9x. 5 | 6 | Video demonstration: 7 | https://www.youtube.com/watch?v=q2wZaBPbj4M 8 | 9 | [![IMAGE ALT TEXT](http://img.youtube.com/vi/q2wZaBPbj4M/0.jpg)](https://www.youtube.com/watch?v=q2wZaBPbj4M "MSX Windows") 10 | 11 | Use it online on Webmsx: 12 | https://webmsx.org/?ROM=https://github.com/albs-br/msx-windows/releases/download/v.0.61.0/msx-windows.rom&MACHINE=MSX1A&FAST_BOOT=1&MOUSE_MODE=1 13 | 14 | Discussion here: https://www.msx.org/forum/msx-talk/development/msx-windows-graphic-os-for-msx-1-poc 15 | 16 | Restrictions: 17 | - Run on 16kb RAM MSX 1 (TMS 9918 VDP), using screen 2 18 | - Should fit on 16kb ROM, with a few small programs, such as: notepad, calc, minesweeper, 19 | task manager, date & time, tic-tac-toe, etc 20 | 21 | The goal here is showing how it is possible for a 1983 8-bit home computer to have the user 22 | experience of an early 90's PC with Windows (even faster, as here there is not swapping file). 23 | The idea is to be frame-fast on all operations. ALT-TAB between 2 maximized programs should be 24 | instantaneous, for example. 25 | 26 | Loading files/programs from disk is possible, but out of the scope for now. 27 | 28 | The OS can run 4 process simultaneously. Each process has a header with vital info (x and y of window, process ID, title, etc). 29 | 30 | The OS has 4 process slots, in which these headers are loaded when the app is open. Besides this, the OS alocates some space in RAM for each process. This space is fixed (currently only 1kb per process, but there is room for around 2,5kb per process on a 16kb of RAM machine). 31 | 32 | There are some app events, that the OS calls when the actions are performed, such as open the app, click, get focus, etc. Each time the OS calls an app event, it passes the process slot addr on register IX, and the process RAM addr space on IY. This arrange makes it possible to the RAM space for variables to be dynamic (grows up or shrink on demand). But this is not implemented yet. 33 | 34 | The main process event is "Work", which is called by the OS only for the active app, the other apps do not make any processing when are on background. This can be easily seen on Settings app, when it loses focus, the clock stops. 35 | 36 | There is a possibility of implementing a BackgroundWork event for the apps opened but out of focus. In this case is up to the app developer to keep the processing on this event as light as possible, or it will slow down the system. 37 | 38 | Each app has also its own 12 tile patterns that can be customized, besides all other OS tiles. They are assigned by the OS on app Open event. 39 | There is still some tile space left on VRAM, meaning it can be grown to around 16 tiles per app in future. 40 | 41 | I have not yet implemented some OS features, as the start menu or dialogs, so I'm not sure on how much tiles there will be left. 42 | 43 | Of course, as the Z80 has no level of protection for processes, the app should be "well behaved" and do not mess up with RAM or VRAM of other processes or OS, nor uses too much CPU. 44 | 45 | One more tech detail: the apps are fixed in ROM, but is possible to make them relocateble, so they can be loaded from disk. I have an idea on how to make this. 46 | 47 | The windows are fixed to the 8x8 grid, to make it pixel precise is possible (due to the 2 colors only) but would become slow I guess. 48 | 49 | I tried to make a minimalist design with only 2 colors (and a little of gray on some mouse overs). It's a visual style of the present day, on an 80's computer. I think the result was pretty good. 50 | 51 | This OS could have been a firmware for the very first MSXs of 1983, with only 16kb of RAM! It would be be crazy, as this kind of user experience turned out to be common only 10 years later on machines 40 times more powerful. 52 | 53 | OS variables amount to just 1855 bytes, that means around 11% of the 16kb of RAM, such a small overhead for a graphic OS. 54 | And I had little to none worries with optimization. ROM size (OS and apps are under 12 kb). Apps are not fully implemented yet. -------------------------------------------------------------------------------- /msx-windows_debug.tcl: -------------------------------------------------------------------------------- 1 | # ram_watch add 0xC01f -type byte -desc nextAvaiProcAddr -format dec 2 | 3 | #ram_watch add 0xC016 -type byte -desc BotRig_Y -format dec 4 | #ram_watch add 0xC023 -type byte -desc BotRig_Y_Min -format dec 5 | 6 | ram_watch add 0xC002 -type byte -desc mouseY -format dec 7 | ram_watch add 0xd74d -type byte -desc Temp -format dec 8 | ram_watch add 0xd74e -type word -desc TempWord -format hex 9 | 10 | 11 | 12 | # OS.windowCorner_BottomRight_X: equ 0C017h ; last def. pass 3 13 | #OS.windowCorner_BottomRight_Y: equ 0C016h ; last def. pass 3 14 | #OS.resizeWindowCorner_BottomRight_Y_Min: equ 0C023h ; last def. pass 3 15 | 16 | # ram_watch add 0xC60B -type word -desc currProcAddr -format hex 17 | # ram_watch add 0xC60d -type word -desc nextAvaiProcAddr -format hex 18 | 19 | 20 | # ram_watch add 0xC01c -type byte -desc currTimeSec -format hex 21 | # ram_watch add 0xC01b -type byte -desc currTimeMin -format hex 22 | # ram_watch add 0xC01a -type byte -desc currTimeHour -format hex 23 | 24 | # ram_watch add 0xC32d -type byte -desc _tileToBeRestored -format dec 25 | # ram_watch add 0xC32e -type word -desc _NAMTBL_addr -format hex 26 | 27 | # OS.mouseOver_tileToBeRestored: equ 0C32Dh ; last def. pass 3 28 | # OS.mouseOver_NAMTBL_addr: equ 0C32Eh ; last def. pass 3 29 | 30 | # OS.processes: equ 0C614h ; last def. pass 3 31 | 32 | # ram_watch add 0xC614 -type byte -desc p0_id -format hex 33 | # ram_watch add 0xC64e -type byte -desc p1_id -format hex 34 | # ram_watch add 0xC688 -type byte -desc p2_id -format hex 35 | # ram_watch add 0xC6c2 -type byte -desc p3_id -format hex 36 | # 37 | # ram_watch add 0xC615 -type byte -desc _p0_state -format dec 38 | # ram_watch add 0xC64f -type byte -desc _p1_state -format dec 39 | # ram_watch add 0xC689 -type byte -desc _p2_state -format dec 40 | # ram_watch add 0xC6c3 -type byte -desc _p3_state -format dec 41 | 42 | # ram_watch add 0xc648 -type byte -desc __p0_prevState -format dec 43 | # ram_watch add 0xC682 -type byte -desc __p1_prevState -format dec 44 | # ram_watch add 0xC6bc -type byte -desc __p2_prevState -format dec 45 | # ram_watch add 0xC6f6 -type byte -desc __p3_prevState -format dec 46 | 47 | # ram_watch add 0xC616 -type byte -desc _p0_width -format dec 48 | 49 | 50 | #ram_watch add 5001a -type byte -desc _p0_layer -format hex 51 | #ram_watch add 50822 -type byte -desc _p1_layer -format hex 52 | #ram_watch add 51634 -type byte -desc _p2_layer -format hex 53 | #ram_watch add 52446 -type byte -desc _p3_layer -format hex 54 | 55 | # ram_watch add 0xd30b -type byte -desc Temp -format hex 56 | 57 | 58 | # ram_watch add 0xC32f -type byte -desc currTileMouseOver -format hex 59 | # 60 | # ram_watch add 0xC72F -type byte -desc IsResizing -format dec 61 | # 62 | # ram_watch add 0xC33F -type byte -desc mouseOver_screenMappingValue -format hex 63 | 64 | # OS.mouseOver_screenMappingValue: equ 0C33Fh ; last def. pass 3 65 | 66 | # IsResizing: equ 0C72Fh ; last def. pass 3 67 | 68 | 69 | # ram_watch add 0xfc48 -type word -desc BOTTOM -format hex 70 | # ram_watch add 0xfc4a -type word -desc HIMEM -format hex 71 | # 72 | # 73 | # ram_watch add 0xC00a -type byte -desc mouseBtn1 -format hex 74 | # ram_watch add 0xC00b -type byte -desc mouseBtn2 -format hex 75 | # 76 | # ram_watch add 0xC002 -type byte -desc mouseY -format dec 77 | # ram_watch add 0xC003 -type byte -desc mouseX -format dec 78 | # ram_watch add 0xC00a -type byte -desc windowCor_Y -format dec 79 | # ram_watch add 0xC00b -type byte -desc windowCor_X -format dec 80 | 81 | 82 | # ram_watch add 0xC018 -type word -desc ticksSinceLastInput -format dec 83 | 84 | -------------------------------------------------------------------------------- /Apps/TicTacToe/Click.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | ; HL = click position in tiles relative to window useful area top left, L = column, H = line 5 | 6 | ;ld b, 1 ; player 1 (X) 7 | ; ld b, 2 ; player 2 (O) 8 | ld a, (iy + TICTACTOE_VARS.CURRENT_PLAYER) 9 | ld b, a 10 | 11 | 12 | 13 | 14 | ld a, l 15 | 16 | ; if (x == 0 || x == 1) isCol_0 17 | or a 18 | jp z, .isCol_0 19 | cp 1 20 | jp z, .isCol_0 21 | 22 | ; if (x == 3 || x == 4) isCol_1 23 | cp 3 24 | jp z, .isCol_1 25 | cp 4 26 | jp z, .isCol_1 27 | 28 | ; if (x == 6 || x == 7) isCol_2 29 | cp 6 30 | jp z, .isCol_2 31 | cp 7 32 | jp z, .isCol_2 33 | 34 | ret 35 | 36 | .isCol_0: 37 | 38 | ld a, h 39 | 40 | ; if (y == 2 || y == 3) isCel_0_0 41 | cp 2 42 | jp z, .isCel_0_0 43 | cp 3 44 | jp z, .isCel_0_0 45 | 46 | ; if (y == 5 || y == 6) isCel_0_1 47 | cp 5 48 | jp z, .isCel_0_1 49 | cp 6 50 | jp z, .isCel_0_1 51 | 52 | ; if (y == 8 || y == 9) isCel_0_2 53 | cp 8 54 | jp z, .isCel_0_2 55 | cp 9 56 | jp z, .isCel_0_2 57 | 58 | ret 59 | 60 | .isCol_1: 61 | 62 | ld a, h 63 | 64 | ; if (y == 2 || y == 3) isCel_1_0 65 | cp 2 66 | jp z, .isCel_1_0 67 | cp 3 68 | jp z, .isCel_1_0 69 | 70 | ; if (y == 5 || y == 6) isCel_1_1 71 | cp 5 72 | jp z, .isCel_1_1 73 | cp 6 74 | jp z, .isCel_1_1 75 | 76 | ; if (y == 8 || y == 9) isCel_1_2 77 | cp 8 78 | jp z, .isCel_1_2 79 | cp 9 80 | jp z, .isCel_1_2 81 | 82 | ret 83 | 84 | .isCol_2: 85 | 86 | ld a, h 87 | 88 | ; if (y == 2 || y == 3) isCel_2_0 89 | cp 2 90 | jp z, .isCel_2_0 91 | cp 3 92 | jp z, .isCel_2_0 93 | 94 | ; if (y == 5 || y == 6) isCel_2_1 95 | cp 5 96 | jp z, .isCel_2_1 97 | cp 6 98 | jp z, .isCel_2_1 99 | 100 | ; if (y == 8 || y == 9) isCel_2_2 101 | cp 8 102 | jp z, .isCel_2_2 103 | cp 9 104 | jp z, .isCel_2_2 105 | 106 | ret 107 | 108 | 109 | .isCel_0_0: 110 | ld de, TICTACTOE_VARS.PLAYFIELD + 0 111 | jp .setCell 112 | 113 | .isCel_0_1: 114 | ld de, TICTACTOE_VARS.PLAYFIELD + 3 115 | jp .setCell 116 | 117 | .isCel_0_2: 118 | ld de, TICTACTOE_VARS.PLAYFIELD + 6 119 | jp .setCell 120 | 121 | ; ---- 122 | 123 | .isCel_1_0: 124 | ld de, TICTACTOE_VARS.PLAYFIELD + 1 125 | jp .setCell 126 | 127 | .isCel_1_1: 128 | ld de, TICTACTOE_VARS.PLAYFIELD + 4 129 | jp .setCell 130 | 131 | .isCel_1_2: 132 | ld de, TICTACTOE_VARS.PLAYFIELD + 7 133 | jp .setCell 134 | 135 | ; ---- 136 | 137 | .isCel_2_0: 138 | ld de, TICTACTOE_VARS.PLAYFIELD + 2 139 | jp .setCell 140 | 141 | .isCel_2_1: 142 | ld de, TICTACTOE_VARS.PLAYFIELD + 5 143 | jp .setCell 144 | 145 | .isCel_2_2: 146 | ld de, TICTACTOE_VARS.PLAYFIELD + 8 147 | jp .setCell 148 | 149 | 150 | .setCell: 151 | push iy ; HL = IY 152 | pop hl 153 | 154 | ; go to correct cell 155 | add hl, de 156 | 157 | ; if cell is already occupied return 158 | ld a, (hl) 159 | or a 160 | ret nz 161 | 162 | ld (hl), b 163 | 164 | 165 | 166 | ; alternate player for next turn 167 | ld a, (iy + TICTACTOE_VARS.CURRENT_PLAYER) 168 | ; if (currentPlayer == 1) currentPlayer == 2 else currentPlayer == 1 169 | cp 1 170 | jp z, .setPlayer_2 171 | 172 | ;setPlayer_1 173 | ld a, 1 174 | jp .continue 175 | 176 | .setPlayer_2: 177 | ld a, 2 178 | .continue: 179 | ld (iy + TICTACTOE_VARS.CURRENT_PLAYER), a 180 | 181 | 182 | 183 | 184 | 185 | ; call "Draw" event of this process 186 | ld e, (ix + PROCESS_STRUCT_IX.drawAddr) ; process.Draw addr (low) 187 | ld d, (ix + PROCESS_STRUCT_IX.drawAddr + 1) ; process.Draw addr (high) 188 | call JP_DE 189 | 190 | ret 191 | -------------------------------------------------------------------------------- /System/Mouse/Mouse.s: -------------------------------------------------------------------------------- 1 | INCLUDE "System/Mouse/DrawMouseCursor.s" 2 | INCLUDE "System/Mouse/MouseClick.s" 3 | INCLUDE "System/Mouse/MouseOver.s" 4 | INCLUDE "System/Mouse/DisableMouseOver.s" 5 | INCLUDE "System/Mouse/DragWindow.s" 6 | INCLUDE "System/Mouse/ResizeWindow.s" 7 | 8 | 9 | 10 | WAIT1: equ 10 ; Short delay value 11 | WAIT2: equ 30 ; Long delay value 12 | 13 | 14 | ; Source (adapted) from https://www.msx.org/wiki/Mouse/Trackball 15 | 16 | ; Routine to read the mouse by direct accesses (works on MSX1/2/2+/turbo R) 17 | ; 18 | ; Input: DE = 01310h for mouse in port 1 (D = 00010011b, E = 00010000b) 19 | ; DE = 06C20h for mouse in port 2 (D = 01101100b, E = 00100000b) 20 | ; Output: 21 | ; H = X-offset, L = Y-offset (H = L = 255 if no mouse) 22 | ; IXH = button 1, IXL = button 2 23 | GTMOUS: 24 | ld b, WAIT2 ; Long delay for first read 25 | call GTOFS2 ; Read bits 7-4 of the x-offset 26 | 27 | ; get mouse buttons (IXH = button 1, IXL = button 2) 28 | ld ix, 0 29 | bit 4, a 30 | jp nz, .mouseButton_1_NotClicked 31 | ld ixh, 1 32 | .mouseButton_1_NotClicked: 33 | bit 5, a 34 | jp nz, .mouseButton_2_NotClicked 35 | ld ixl, 1 36 | .mouseButton_2_NotClicked: 37 | 38 | and 0x0F 39 | rlca 40 | rlca 41 | rlca 42 | rlca 43 | ld c, a 44 | call GTOFST ; Read bits 3-0 of the x-offset 45 | and 0x0F 46 | or c 47 | ld h, a ; Store combined x-offset 48 | call GTOFST ; Read bits 7-4 of the y-offset 49 | and 0x0F 50 | rlca 51 | rlca 52 | rlca 53 | rlca 54 | ld c, a 55 | call GTOFST ; Read bits 3-0 of the y-offset 56 | and 0x0F 57 | or c 58 | ld l, a ; Store combined y-offset 59 | ret 60 | 61 | GTOFST: 62 | ld b, WAIT1 63 | GTOFS2: 64 | ld a, 15 ; Read PSG register 15 for mouse 65 | ;di ; DI useless if the routine is used during an interrupt 66 | out (0xA0), a 67 | in a, (0xA1) 68 | and 0x80 ; preserve LED code/Kana state 69 | or d ; mouse1 x0010011b / mouse2 x1101100b 70 | out (0xA1), a 71 | xor e 72 | ld d, a 73 | 74 | call WAITMS ; Extra delay because the mouse is slow 75 | 76 | ld a, 14 77 | out (0xA0), a 78 | ;ei ; EI useless if the routine is used during an interrupt 79 | in a, (0xA2) 80 | ret 81 | WAITMS: 82 | ld a, b 83 | WTTR: 84 | djnz WTTR 85 | db 0xED,0x55 ; Back if Z80 (RETN on Z80, NOP on R800) 86 | rlca 87 | rlca 88 | ld b, a 89 | WTTR2: 90 | djnz WTTR2 91 | ld b, a 92 | WTTR3: 93 | djnz WTTR3 94 | 95 | ret 96 | 97 | ; Input: 98 | ; E = delta X 99 | ; D = delta Y 100 | ; L = current X 101 | ; H = current Y 102 | ; Output: 103 | ; L = updated X 104 | ; H = updated Y 105 | CLIPADD: 106 | ; Make sure that mouse pointer stays inside visible screen area 107 | ld a, l 108 | ld b, e 109 | call LIMITADD 110 | ld l, a 111 | 112 | ld a, h 113 | ld b, d 114 | call LIMITADD 115 | ld h, a 116 | cp 191 117 | ret c 118 | ld h, 191 119 | ret 120 | 121 | LIMITADD: 122 | 123 | ; Clip mouse pointer to 0..255 124 | ; In: A = mouse position 0..255 125 | ; B = mouse move -128..+127 126 | ; Out: A = new mouse position 0..255 127 | 128 | 129 | sub 128 ; move from range 0..255 to -128..+127 130 | add a, b ; add mouse offset, both numbers are signed 131 | jp pe, .CLIP ; pe -> previous instruction caused a signed overflow 132 | add a, 128 ; move back to range 0..255 133 | ret ; 134 | .CLIP: 135 | ld a, b ; get mouse offset 136 | cpl ; flip all bits (only bit 7 matters) 137 | add a, a ; move bit 7 to carry flag 138 | sbc a, a ; carry set -> a=255 carry not set -> a=0 139 | ret ; 140 | 141 | 142 | 143 | ; get mouse position in pixels (x, y) convert it to tiles (col, line), and return it 144 | ; Inputs: nothing 145 | ; Output: 146 | ; L = column (0-31) 147 | ; H = line (0-23) 148 | GET_MOUSE_POSITION_IN_TILES: 149 | ld a, (OS.mouseY) 150 | ; dec a ; because of the Y + 1 TMS9918 bug 151 | 152 | ; divide by 8 153 | srl a ; shift right n, bit 7 = 0, carry = 0 154 | srl a ; shift right n, bit 7 = 0, carry = 0 155 | srl a ; shift right n, bit 7 = 0, carry = 0 156 | ld h, a 157 | 158 | 159 | ld a, (OS.mouseX) 160 | 161 | ; divide by 8 162 | srl a ; shift right n, bit 7 = 0, carry = 0 163 | srl a ; shift right n, bit 7 = 0, carry = 0 164 | srl a ; shift right n, bit 7 = 0, carry = 0 165 | ld l, a 166 | 167 | ret -------------------------------------------------------------------------------- /System/Mouse/DrawMouseCursor.s: -------------------------------------------------------------------------------- 1 | _DRAW_MOUSE_CURSOR: 2 | 3 | 4 | ld hl, SPRATR 5 | call BIOS_SETWRT 6 | ld c, PORT_0 7 | ld hl, OS.mouseSpriteAttributes 8 | 9 | ld a, (hl) ; fix Y+1 bug of TMS 9918 10 | dec a 11 | inc hl 12 | out (c), a ; .mouseY: 13 | 14 | ; TODO: this can be improved a bit (11 cycles instead of 15) 15 | ; jp $ + 3 ; 11 cycles 16 | ; ld de, 0x0000 ; 11 cycles 17 | nop 18 | nop 19 | nop 20 | outi ; .mouseX: 21 | 22 | nop 23 | nop 24 | nop 25 | outi ; .mousePattern: 26 | 27 | nop 28 | nop 29 | nop 30 | outi ; .mouseColor: 31 | 32 | ld a, (hl) ; fix Y+1 bug of TMS 9918 33 | dec a 34 | inc hl 35 | out (c), a ; .mouseY_1: 36 | 37 | nop 38 | nop 39 | nop 40 | outi ; .mouseX_1: 41 | 42 | nop 43 | nop 44 | nop 45 | outi ; .mousePattern_1: 46 | 47 | nop 48 | nop 49 | nop 50 | outi ; .mouseColor_1: 51 | 52 | 53 | 54 | ; ; update mouse cursor sprites 55 | ; ld hl, SPRATR 56 | ; call BIOS_SETWRT 57 | ; ld hl, OS.mouseSpriteAttributes 58 | ; ld c, PORT_0 59 | ; ld b, 8 60 | ; .loop_1: 61 | ; outi 62 | ; jp nz, .loop_1 ; this uses exactly 29 cycles (t-states) 63 | 64 | ; if (!OS.isDraggingWindow && !OS.isResizingWindow) skip window corner sprites 65 | ld a, (OS.isDraggingWindow) 66 | ld b, a 67 | ld a, (OS.isResizingWindow) 68 | or b 69 | jp z, .skip_1 70 | 71 | ld a, (hl) ; fix Y+1 bug of TMS 9918 72 | dec a 73 | inc hl 74 | out (c), a ; .windowCorner_TopLeft_Y 75 | 76 | nop 77 | nop 78 | nop 79 | outi ; .windowCorner_TopLeft_X 80 | 81 | nop 82 | nop 83 | nop 84 | outi ; .windowCorner_TopLeft_Pattern 85 | 86 | nop 87 | nop 88 | nop 89 | outi ; .windowCorner_TopLeft_Color 90 | ; ---- 91 | 92 | ld a, (hl) ; fix Y+1 bug of TMS 9918 93 | dec a 94 | inc hl 95 | out (c), a ; .windowCorner_TopRight_Y 96 | 97 | nop 98 | nop 99 | nop 100 | outi ; .windowCorner_TopRight_X 101 | 102 | nop 103 | nop 104 | nop 105 | outi ; .windowCorner_TopRight_Pattern 106 | 107 | nop 108 | nop 109 | nop 110 | outi ; .windowCorner_TopRight_Color 111 | ; ---- 112 | 113 | ld a, (hl) ; fix Y+1 bug of TMS 9918 114 | dec a 115 | inc hl 116 | out (c), a ; .windowCorner_BottomLeft_Y 117 | 118 | nop 119 | nop 120 | nop 121 | outi ; .windowCorner_BottomLeft_X 122 | 123 | nop 124 | nop 125 | nop 126 | outi ; .windowCorner_BottomLeft_Pattern 127 | 128 | nop 129 | nop 130 | nop 131 | outi ; .windowCorner_BottomLeft_Color 132 | ; ---- 133 | 134 | ld a, (hl) ; fix Y+1 bug of TMS 9918 135 | dec a 136 | inc hl 137 | out (c), a ; .windowCorner_BottomRight_Y 138 | 139 | nop 140 | nop 141 | nop 142 | outi ; .windowCorner_BottomRight_X 143 | 144 | nop 145 | nop 146 | nop 147 | outi ; .windowCorner_BottomRight_Pattern 148 | 149 | nop 150 | nop 151 | nop 152 | outi ; .windowCorner_BottomRight_Color 153 | ; ---- 154 | 155 | 156 | 157 | .skip_1: 158 | nop 159 | nop 160 | ld a, 208 161 | out (c), a ; hide all other sprites 162 | 163 | 164 | 165 | ; check mouse position on screen (OS.screenMapping) 166 | ld a, (OS.mouseX) ; mouse x in pixels (0-255) 167 | ; divide by 8 to convert to columns (0-31) 168 | srl a ; shift right n, bit 7 = 0, carry = 0 169 | srl a ; shift right n, bit 7 = 0, carry = 0 170 | srl a ; shift right n, bit 7 = 0, carry = 0 171 | ld l, a 172 | 173 | ld a, (OS.mouseY) ; mouse y in pixels (0-191) 174 | ; divide by 8 to convert to lines (0-23) 175 | srl a ; shift right n, bit 7 = 0, carry = 0 176 | srl a ; shift right n, bit 7 = 0, carry = 0 177 | srl a ; shift right n, bit 7 = 0, carry = 0 178 | ld h, a 179 | 180 | call _CONVERT_COL_LINE_TO_LINEAR 181 | 182 | ld bc, OS.screenMapping 183 | add hl, bc 184 | 185 | ld a, (hl) 186 | 187 | ld (OS.currentTileMouseOver), a 188 | 189 | 190 | 191 | 192 | 193 | ret 194 | 195 | ; .mouseOverTaskbar: 196 | ; call BIOS_BEEP 197 | ; ret 198 | -------------------------------------------------------------------------------- /Apps/Calc/Data.s: -------------------------------------------------------------------------------- 1 | 2 | .CALC_DISPLAY_TILES: 3 | db TILE_WINDOW_TITLE_MIDDLE_TOP 4 | db TILE_WINDOW_TITLE_MIDDLE_TOP 5 | db TILE_WINDOW_TITLE_MIDDLE_TOP 6 | db TILE_WINDOW_TITLE_MIDDLE_TOP 7 | db TILE_WINDOW_TITLE_MIDDLE_TOP 8 | db TILE_WINDOW_TITLE_MIDDLE_TOP 9 | db TILE_WINDOW_TITLE_MIDDLE_TOP 10 | db TILE_WINDOW_TITLE_MIDDLE_TOP 11 | db TILE_WINDOW_TITLE_MIDDLE_TOP 12 | db TILE_WINDOW_TITLE_MIDDLE_TOP 13 | db TILE_WINDOW_TITLE_MIDDLE_TOP 14 | db TILE_WINDOW_TITLE_MIDDLE_TOP 15 | 16 | db TILE_EMPTY_BLACK 17 | db TILE_EMPTY_BLACK 18 | db TILE_EMPTY_BLACK 19 | db TILE_EMPTY_BLACK 20 | db TILE_EMPTY_BLACK 21 | db TILE_EMPTY_BLACK 22 | db TILE_EMPTY_BLACK 23 | db TILE_EMPTY_BLACK 24 | db TILE_EMPTY_BLACK 25 | db TILE_FONT_REVERSED_NUMBERS_0 + 1 ; debug 26 | db TILE_FONT_REVERSED_NUMBERS_0 + 2 27 | db TILE_FONT_REVERSED_NUMBERS_0 + 3 28 | 29 | ; --------- keypad 30 | ; ----- 31 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 32 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 33 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 34 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 35 | 36 | db TILE_LINE_VERTICAL, TILE_FONT_NUMBERS_0 + 7, TILE_WINDOW_BORDER_RIGHT 37 | db TILE_LINE_VERTICAL, TILE_FONT_NUMBERS_0 + 8, TILE_WINDOW_BORDER_RIGHT 38 | db TILE_LINE_VERTICAL, TILE_FONT_NUMBERS_0 + 9, TILE_WINDOW_BORDER_RIGHT 39 | db TILE_LINE_VERTICAL, TILE_SLASH, TILE_WINDOW_BORDER_RIGHT 40 | 41 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 42 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 43 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 44 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 45 | 46 | ; ----- 47 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 48 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 49 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 50 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 51 | 52 | db TILE_LINE_VERTICAL, TILE_FONT_NUMBERS_0 + 4, TILE_WINDOW_BORDER_RIGHT 53 | db TILE_LINE_VERTICAL, TILE_FONT_NUMBERS_0 + 5, TILE_WINDOW_BORDER_RIGHT 54 | db TILE_LINE_VERTICAL, TILE_FONT_NUMBERS_0 + 6, TILE_WINDOW_BORDER_RIGHT 55 | db TILE_LINE_VERTICAL, TILE_STAR, TILE_WINDOW_BORDER_RIGHT 56 | 57 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 58 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 59 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 60 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 61 | 62 | ; ----- 63 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 64 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 65 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 66 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 67 | 68 | db TILE_LINE_VERTICAL, TILE_FONT_NUMBERS_0 + 1, TILE_WINDOW_BORDER_RIGHT 69 | db TILE_LINE_VERTICAL, TILE_FONT_NUMBERS_0 + 2, TILE_WINDOW_BORDER_RIGHT 70 | db TILE_LINE_VERTICAL, TILE_FONT_NUMBERS_0 + 3, TILE_WINDOW_BORDER_RIGHT 71 | db TILE_LINE_VERTICAL, TILE_MINUS, TILE_WINDOW_BORDER_RIGHT 72 | 73 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 74 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 75 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 76 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 77 | 78 | ; ----- 79 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 80 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 81 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 82 | db TILE_LINE_TOP_LEFT, TILE_LINE_HORIZONTAL, TILE_LINE_TOP_RIGHT 83 | 84 | db TILE_LINE_VERTICAL, TILE_FONT_NUMBERS_0 + 0, TILE_WINDOW_BORDER_RIGHT 85 | db TILE_LINE_VERTICAL, TILE_DOT, TILE_WINDOW_BORDER_RIGHT 86 | db TILE_LINE_VERTICAL, TILE_EQUAL, TILE_WINDOW_BORDER_RIGHT 87 | db TILE_LINE_VERTICAL, TILE_PLUS, TILE_WINDOW_BORDER_RIGHT 88 | 89 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 90 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 91 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 92 | db TILE_LINE_BOTTOM_LEFT, TILE_WINDOW_BORDER_MIDDLE_BOTTOM, TILE_LINE_BOTTOM_RIGHT_SHADOW 93 | 94 | -------------------------------------------------------------------------------- /System/Process/Process.s: -------------------------------------------------------------------------------- 1 | INCLUDE "System/Process/LoadProcess.s" 2 | INCLUDE "System/Process/SetCurrentProcess.s" 3 | INCLUDE "System/Process/CloseProcess.s" 4 | INCLUDE "System/Process/MinimizeProcess.s" 5 | INCLUDE "System/Process/MaximizeProcess.s" 6 | INCLUDE "System/Process/RestoreProcess.s" 7 | INCLUDE "System/Process/MinimizeAllProcesses.s" 8 | 9 | 10 | 11 | MAX_PROCESS_ID: equ 3 ; max 4 processes available (maybe 6 in the future) 12 | 13 | 14 | 15 | ; Input: nothing 16 | ; Output: 17 | ; IXH = next available process id (between 0 and MAX_PROCESS_ID-1), 255 means no process space available 18 | _GET_NEXT_AVAILABLE_PROCESS_ID: 19 | ld ixh, 0 ; first process id to be searched 20 | 21 | .outerLoop: 22 | ld hl, OS.processes 23 | 24 | .loop: 25 | ld a, (hl) 26 | cp ixh 27 | jp z, .goToNext ; process id found 28 | 29 | ld bc, Process_struct.size 30 | add hl, bc ; go to next process slot on memory 31 | 32 | ; check if process space ended 33 | ld de, OS.processes_end 34 | call BIOS_DCOMPR ; Compare Contents Of HL & DE, Set Z-Flag IF (HL == DE), Set CY-Flag IF (HL < DE) 35 | jp nz, .loop 36 | 37 | ; if processes id on ixh wasn't found, it is the next available 38 | ret 39 | 40 | .goToNext: 41 | inc ixh 42 | ld a, ixh 43 | cp MAX_PROCESS_ID + 1 44 | jp nz, .outerLoop 45 | 46 | ; if searched for each possible process id on each processes slot, then OS max process limit was reached 47 | ld ixh, 255 48 | 49 | ret 50 | 51 | 52 | ; Input: nothing 53 | ; Output: 54 | ; HL: addr of process slot, if available, HL = 0xffff if no process slot available 55 | _GET_NEXT_AVAILABLE_PROCESS_ADDR: 56 | 57 | ld hl, OS.processes 58 | ld de, Process_struct.size 59 | ld b, MAX_PROCESS_ID + 1 60 | .loop: 61 | ld a, (hl) 62 | ; process id = 255 means that this process slot is available 63 | inc a ; if (A == 255) return 64 | ret z 65 | 66 | add hl, de 67 | 68 | djnz .loop 69 | 70 | ; if no process slot available return HL = 0xffff 71 | ld hl, 0xffff 72 | 73 | ret 74 | 75 | 76 | 77 | ; Input: nothing 78 | ; Output: 79 | ; A: number of processes currently opened 80 | _GET_NUMBER_OF_PROCESSES_OPENED: 81 | 82 | ld hl, OS.processes 83 | ld de, Process_struct.size 84 | ld b, MAX_PROCESS_ID + 1 85 | xor a ; number of processes counter 86 | .loop: 87 | ld c, (hl) 88 | ; process id = 255 means that this process slot is available 89 | inc c ; if (C == 255) next 90 | jp z, .next 91 | 92 | ; process found, increment counter 93 | inc a 94 | 95 | .next: 96 | add hl, de 97 | 98 | djnz .loop 99 | 100 | ret 101 | 102 | 103 | 104 | ; Input: 105 | ; C = process id 106 | ; Output 107 | ; z = process found 108 | ; nz = process not found 109 | ; HL = addr of process; 0x0000 if not found 110 | _GET_PROCESS_BY_ID: 111 | ; loop through process slots looking for this process id 112 | ld hl, OS.processes 113 | ld de, Process_struct.size 114 | ld b, MAX_PROCESS_ID + 1 115 | .loop_1: 116 | ld a, (hl) 117 | cp c 118 | ret z 119 | add hl, de 120 | djnz .loop_1 121 | 122 | ; not found 123 | ld hl, 0x0000 124 | xor a ; reset z flag 125 | 126 | ret 127 | 128 | 129 | ; ------------------------------- logic for ajust layer of processes: 130 | 131 | ; LoadProcess: 132 | ; get number of current processes and make it the layer number (0-3) 133 | 134 | 135 | ; CloseProcess: 136 | ; after removing the process from OS process slots decrease layer number of all processes with layer > L 137 | 138 | 139 | ; SetCurrentProcess: 140 | ; 141 | ; 2 142 | ; 0 <-- new current 143 | ; 3 144 | ; 1 145 | 146 | ; 1 147 | ; 3 148 | ; 2 149 | ; 0 150 | 151 | ; ---- 152 | 153 | ; 2 154 | ; 1 <-- new current 155 | ; 0 156 | ; 3 157 | 158 | ; 1 159 | ; 3 160 | ; 0 161 | ; 2 162 | 163 | ; set the new current layer to NUMBER_OF_PROCESSES 164 | ; dec layer of all processes with layer > old layer 165 | 166 | 167 | 168 | ; Decrease layer of all processes with layer > C 169 | ; Input: 170 | ; C = layer number 171 | _ADJUST_LAYER_OF_PROCESSES: 172 | 173 | ld hl, OS.processes + PROCESS_STRUCT_IX.layer 174 | ld de, Process_struct.size 175 | ld b, MAX_PROCESS_ID + 1 176 | .loop: 177 | ld a, (hl) 178 | cp 0xff 179 | jp z, .next ; if (A == 255) .next 180 | 181 | cp c 182 | jp c, .next ; if (C > A) .next 183 | 184 | ; if (C <= A) layer -- 185 | dec a 186 | ld (hl), a 187 | 188 | .next: 189 | add hl, de 190 | 191 | djnz .loop 192 | 193 | ret 194 | 195 | -------------------------------------------------------------------------------- /System/Init/InitVdp.s: -------------------------------------------------------------------------------- 1 | ; Default VRAM tables for Screen 2 2 | PATTBL: equ 0x0000 ; to 0x17ff (6144 bytes) 3 | NAMTBL: equ 0x1800 ; to 0x1aff (768 bytes) 4 | SPRATR: equ 0x1b00 ; to 0x1b7f (128 bytes) 5 | 6 | NAMTBL_ALT: equ 0x1c00 ; to 0x1eff (768 bytes) 7 | 8 | COLTBL: equ 0x2000 ; to 0x37ff (6144 bytes) 9 | SPRPAT: equ 0x3800 ; to 0x3fff (2048 bytes) 10 | 11 | 12 | 13 | _INIT_VDP: 14 | 15 | 16 | ; define screen colors 17 | ld a, 15 ; Foreground color 18 | ld (BIOS_FORCLR), a 19 | ld a, 1 ; Background color 20 | ld (BIOS_BAKCLR), a 21 | ld a, 4 ; Border color 22 | ld (BIOS_BDRCLR), a 23 | call BIOS_CHGCLR ; Change Screen Color 24 | 25 | ;call BIOS_INIGRP ; screen 2 26 | ld a, 2 27 | call BIOS_CHGMOD 28 | 29 | call SetSprites16x16 30 | 31 | ; 1 1 32 | ; 4 0 8 7 0 33 | ; NAMTBL_A: 0x1800 0001 1000 0000 0000 b 34 | ; NAMTBL_B: 0x1000 0001 0000 0000 0000 b 35 | ; set NAMTBL to 0x1800 36 | ld c, 2 ; VDP Register Number (0..27, 32..46) 37 | ld b, 0000 0110 b ; Data To Write 38 | call BIOS_WRTVDP ; 39 | 40 | 41 | call BIOS_DISSCR 42 | 43 | 44 | ; --------------------- init VRAM ----------- 45 | 46 | ; clear VRAM 47 | xor a ; value 48 | ld bc, 1024 * 16 ; size 49 | ld hl, 0x0000 ; start VRAM address 50 | call BIOS_FILVRM 51 | 52 | ; load PATTBL 53 | ld hl, TILE_PATTERNS ; RAM address (source) 54 | ld de, PATTBL ; VRAM address (destiny) 55 | ld bc, TILE_PATTERNS.size ; Block length 56 | call BIOS_LDIRVM ; Block transfer to VRAM from memory 57 | 58 | ld hl, TILE_PATTERNS ; RAM address (source) 59 | ld de, PATTBL + (256 * 8) ; VRAM address (destiny) 60 | ld bc, TILE_PATTERNS.size ; Block length 61 | call BIOS_LDIRVM ; Block transfer to VRAM from memory 62 | 63 | ld hl, TILE_PATTERNS ; RAM address (source) 64 | ld de, PATTBL + (512 * 8) ; VRAM address (destiny) 65 | ld bc, TILE_PATTERNS.size ; Block length 66 | call BIOS_LDIRVM ; Block transfer to VRAM from memory 67 | 68 | ; fill COLTBL with black on white bg 69 | ld a, 0x1f ; value 70 | ld bc, 256 * 8 * 3 ; size 71 | ld hl, COLTBL ; start VRAM address 72 | call BIOS_FILVRM 73 | 74 | ; fill COLTBL for font reversed (first part) 75 | ld a, 0xf1 ; value 76 | ld bc, TILE_FONT_REVERSED_PATTERNS.size ; size 77 | ld hl, COLTBL + (TILE_FONT_REVERSED_PATTERNS - TILE_PATTERNS) ; start VRAM address 78 | call BIOS_FILVRM 79 | ; fill COLTBL for font reversed (second part) 80 | ld a, 0xf1 ; value 81 | ld bc, TILE_FONT_REVERSED_PATTERNS.size ; size 82 | ld hl, COLTBL + (256 * 8) + (TILE_FONT_REVERSED_PATTERNS - TILE_PATTERNS) ; start VRAM address 83 | call BIOS_FILVRM 84 | ; fill COLTBL for font reversed (third part) 85 | ld a, 0xf1 ; value 86 | ld bc, TILE_FONT_REVERSED_PATTERNS.size ; size 87 | ld hl, COLTBL + (512 * 8) + (TILE_FONT_REVERSED_PATTERNS - TILE_PATTERNS) ; start VRAM address 88 | call BIOS_FILVRM 89 | 90 | ; fill COLTBL for tiles filled with colors (first part) 91 | ld hl, COLTBL + (TILE_FILLED_COLORS_PATTERNS - TILE_PATTERNS) ; start VRAM address 92 | call .fillTileColor 93 | 94 | 95 | ; fill COLTBL for tiles filled with colors (second part) 96 | ld hl, COLTBL + (256 * 8) + (TILE_FILLED_COLORS_PATTERNS - TILE_PATTERNS) ; start VRAM address 97 | call .fillTileColor 98 | 99 | ; fill COLTBL for tiles filled with colors (third part) 100 | ld hl, COLTBL + (512 * 8) + (TILE_FILLED_COLORS_PATTERNS - TILE_PATTERNS) ; start VRAM address 101 | call .fillTileColor 102 | 103 | 104 | 105 | ; load SPRPAT 106 | ld hl, SPRITE_PATTERNS ; RAM address (source) 107 | ld de, SPRPAT ; VRAM address (destiny) 108 | ld bc, SPRITE_PATTERNS.size ; Block length 109 | call BIOS_LDIRVM ; Block transfer to VRAM from memory 110 | 111 | 112 | call BIOS_ENASCR 113 | 114 | ret 115 | 116 | .fillTileColor: 117 | ld d, 2 118 | .loop_Colors: 119 | push hl, de 120 | ; ld a, 0x21 ; value 121 | sla d ; shift left R; bit 7 -> C ; bit 0 -> 0 122 | sla d ; shift left R; bit 7 -> C ; bit 0 -> 0 123 | sla d ; shift left R; bit 7 -> C ; bit 0 -> 0 124 | sla d ; shift left R; bit 7 -> C ; bit 0 -> 0 125 | 126 | ld a, 0000 0001 b 127 | or d 128 | 129 | ld bc, 8 130 | call BIOS_FILVRM 131 | pop de, hl 132 | 133 | ld bc, 8 134 | add hl, bc 135 | 136 | inc d 137 | ld a, d 138 | cp 15 139 | jp nz, .loop_Colors 140 | 141 | ret 142 | -------------------------------------------------------------------------------- /System/Window/Window.s: -------------------------------------------------------------------------------- 1 | INCLUDE "System/Window/DrawWindow.s" 2 | INCLUDE "System/Window/CloseWindow.s" 3 | INCLUDE "System/Window/ScreenMapping.s" 4 | INCLUDE "System/Window/DrawOnWindowUsefulArea.s" 5 | INCLUDE "System/Window/SetCustomTile.s" 6 | 7 | 8 | 9 | ; Convert (col, line) in LH to linear addr (0-767), ie: (line * 32) + col 10 | ; Inputs: 11 | ; L = column (0-31) 12 | ; H = line (0-23) 13 | ; Output: 14 | ; HL = linear addr (0-767) 15 | _CONVERT_COL_LINE_TO_LINEAR: 16 | 17 | ; from: 18 | ; 19 | ; | Register H | Register L | 20 | ; | 0 0 0 Y4 Y3 Y2 Y1 Y0 | 0 0 0 X4 X3 X2 X1 X0 | 21 | ; 22 | ; to: 23 | ; 24 | ; | Register H | Register L | 25 | ; | 0 0 0 0 0 0 Y4 Y3 | Y2 Y1 Y0 X4 X3 X2 X1 X0 | 26 | ; | 0 0 0 0 0 0 A9 A8 | A7 A6 A5 A4 A3 A2 A1 A0 | 27 | 28 | xor a ; A = 0 29 | 30 | srl h ; shift right n, bit 0 goes to carry flag and bit 7 zeroed. 31 | rra ; rotates A to the right with the carry put into bit 7 and bit 0 put into the carry flag. 32 | srl h 33 | rra 34 | srl h 35 | rra 36 | 37 | or l ; joins A7-A5 in A register to A4-A0 in L register 38 | ld l, a 39 | 40 | ret 41 | 42 | 43 | ; Input: 44 | ; IX = addr of process header 45 | ; Output: 46 | ; HL = VRAM NAMTBL addr position of top left of useful area 47 | ; of window (area that the process can use) 48 | GET_USEFUL_WINDOW_BASE_NAMTBL: 49 | 50 | ; if (windowState == MAXIMIZED) ... 51 | ld a, (ix + PROCESS_STRUCT_IX.windowState) 52 | cp WINDOW_STATE.MAXIMIZED 53 | jp z, .isMaximized 54 | 55 | ; get variables from process 56 | ld l, (ix + PROCESS_STRUCT_IX.x) ; process.x 57 | ld h, (ix + PROCESS_STRUCT_IX.y) ; process.y 58 | 59 | call _CONVERT_COL_LINE_TO_LINEAR 60 | 61 | ld bc, NAMTBL + (32 * 2) + 1; two lines below and one column right 62 | add hl, bc 63 | 64 | ret 65 | 66 | .isMaximized: 67 | ; if maximized, the position is NAMTBL + 32, 68 | ; as maximized windows has no borders 69 | ; and title is just one tile tall 70 | ld hl, NAMTBL + 32 71 | 72 | ret 73 | 74 | 75 | 76 | ; Input: 77 | ; IX = addr of process header 78 | ; Output: 79 | ; HL = VRAM NAMTBL addr position of top left of window (title) 80 | _GET_WINDOW_TITLE_BASE_NAMTBL: 81 | 82 | ; if (windowState == MAXIMIZED) the position is simply NAMTBL 83 | ld a, (ix + PROCESS_STRUCT_IX.windowState) 84 | cp WINDOW_STATE.MAXIMIZED 85 | jp z, .isMaximized 86 | 87 | ; get variables from process 88 | ld l, (ix + PROCESS_STRUCT_IX.x) ; process.x 89 | ld h, (ix + PROCESS_STRUCT_IX.y) ; process.y 90 | 91 | call _CONVERT_COL_LINE_TO_LINEAR 92 | 93 | ld bc, NAMTBL 94 | add hl, bc 95 | 96 | ret 97 | 98 | .isMaximized: 99 | ld hl, NAMTBL 100 | 101 | ret 102 | 103 | 104 | 105 | ; Input: 106 | ; IX = addr of process header 107 | ; Output: 108 | ; A = width in tiles (1-32) 109 | GET_WINDOW_USEFUL_WIDTH: 110 | ld a, (ix + PROCESS_STRUCT_IX.windowState) 111 | cp WINDOW_STATE.RESTORED 112 | jp z, .isRestored 113 | 114 | ; window maximized 115 | ld a, 32 116 | 117 | ret 118 | 119 | .isRestored: 120 | ld a, (ix + PROCESS_STRUCT_IX.width) 121 | sub 2 ; 1 for left border, 1 for right border 122 | 123 | ret 124 | 125 | 126 | 127 | ; Input: 128 | ; IX = addr of process header 129 | ; Output: 130 | ; A = width in tiles (1-22) 131 | GET_WINDOW_USEFUL_HEIGHT: 132 | 133 | ld a, (ix + PROCESS_STRUCT_IX.windowState) 134 | cp WINDOW_STATE.RESTORED 135 | jp z, .isRestored 136 | 137 | ; window maximized 138 | ld a, 24 - 2 - 1 ; 2 for taskbar, 1 for title 139 | 140 | ret 141 | 142 | .isRestored: 143 | ld a, (ix + PROCESS_STRUCT_IX.height) 144 | sub 3 ; 2 for window title, 1 for window bottom 145 | 146 | ret 147 | 148 | 149 | 150 | ; TODO: test it 151 | ; Input: 152 | ; IX = addr of process header 153 | ; Output: 154 | ; A = last useful column (0-31) 155 | GET_WINDOW_LAST_USEFUL_COLUMN: 156 | ld a, (ix + PROCESS_STRUCT_IX.windowState) 157 | cp WINDOW_STATE.RESTORED 158 | jp z, .isRestored 159 | 160 | ; window maximized 161 | ld a, 31 162 | 163 | ret 164 | 165 | .isRestored: 166 | ld a, (ix + PROCESS_STRUCT_IX.x) 167 | ld b, (ix + PROCESS_STRUCT_IX.width) 168 | sub 4 169 | add b 170 | 171 | ret 172 | 173 | 174 | 175 | ; Input: 176 | ; IX = addr of process header 177 | ; Output: 178 | ; HL = VRAM NAMTBL addr position of top RIGHT of useful area 179 | ; of window (area that the process can use) 180 | GET_WINDOW_NAMTBL_LAST_USEFUL_COLUMN: 181 | 182 | ; if (windowState == MAXIMIZED) ... 183 | ld a, (ix + PROCESS_STRUCT_IX.windowState) 184 | cp WINDOW_STATE.MAXIMIZED 185 | jp z, .isMaximized 186 | 187 | ; get variables from process 188 | ld a, (ix + PROCESS_STRUCT_IX.x) ; process.x 189 | ld b, (ix + PROCESS_STRUCT_IX.width) 190 | add b 191 | sub 2 ; discount 2 columns of border right 192 | ld l, a 193 | 194 | ld h, (ix + PROCESS_STRUCT_IX.y) ; process.y 195 | 196 | call _CONVERT_COL_LINE_TO_LINEAR 197 | 198 | ld bc, NAMTBL + (32 * 2); two lines below 199 | add hl, bc 200 | 201 | ret 202 | 203 | 204 | .isMaximized: 205 | ld hl, NAMTBL + 32 + 31 ; last column of screen, one line below top 206 | 207 | ret 208 | -------------------------------------------------------------------------------- /Apps/Tetra/Open.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | ; init seed of random numbers 6 | ld a, (BIOS_JIFFY) 7 | or 0x80 8 | ld (Seed), a 9 | 10 | ; load custom tiles 11 | xor a 12 | ld hl, Tetra_Data.TILE_pattern 13 | ld de, Tetra_Data.TILE_LIGHT_BLUE_colors 14 | call SET_CUSTOM_TILE 15 | 16 | ld a, 1 17 | ld hl, Tetra_Data.TILE_pattern 18 | ld de, Tetra_Data.TILE_RED_colors 19 | call SET_CUSTOM_TILE 20 | 21 | ld a, 2 22 | ld hl, Tetra_Data.TILE_pattern 23 | ld de, Tetra_Data.TILE_YELLOW_colors 24 | call SET_CUSTOM_TILE 25 | 26 | ld a, 3 27 | ld hl, Tetra_Data.TILE_pattern 28 | ld de, Tetra_Data.TILE_PURPLE_colors 29 | call SET_CUSTOM_TILE 30 | 31 | ld a, 4 32 | ld hl, Tetra_Data.TILE_pattern 33 | ld de, Tetra_Data.TILE_GRAY_colors 34 | call SET_CUSTOM_TILE 35 | 36 | ld a, 5 37 | ld hl, Tetra_Data.TILE_pattern 38 | ld de, Tetra_Data.TILE_GREEN_colors 39 | call SET_CUSTOM_TILE 40 | 41 | ld a, 6 42 | ld hl, Tetra_Data.TILE_pattern 43 | ld de, Tetra_Data.TILE_BLUE_colors 44 | call SET_CUSTOM_TILE 45 | 46 | ; init empty playfield and playfield buffer 47 | ld de, TETRA_VARS.PLAYFIELD 48 | push iy ; HL = IY 49 | pop hl 50 | add hl, de 51 | push hl 52 | ld de, TETRA_VARS.PLAYFIELD_BUFFER 53 | push iy ; HL = IY 54 | pop hl 55 | add hl, de 56 | ex de, hl 57 | pop hl 58 | xor a 59 | ld b, TETRA_CONSTANTS.PLAYFIELD_WIDTH * TETRA_CONSTANTS.PLAYFIELD_HEIGHT 60 | .loop_1: 61 | ld (hl), a 62 | ld (de), a 63 | inc hl 64 | inc de 65 | djnz .loop_1 66 | 67 | 68 | 69 | ; ; debug 70 | ; ld de, TETRA_VARS.PLAYFIELD + 9 + (17*10) 71 | ; push iy ; HL = IY 72 | ; pop hl 73 | ; add hl, de 74 | ; ld a, (ix + PROCESS_STRUCT_IX.vramStartTile) 75 | ; ld (hl), a 76 | 77 | 78 | call .LoadRandomPiece 79 | 80 | 81 | ; init vars 82 | xor a 83 | ld (iy + TETRA_VARS.COUNTER), a 84 | 85 | ret 86 | 87 | ; ------ 88 | .LoadRandomPiece: 89 | 90 | ; generate random number between 1 and 7 91 | call RandomNumber 92 | and 0000 0111 b ; keep value in the 0-7 range 93 | or a ; repeat if A=0 94 | jp z, .LoadRandomPiece 95 | 96 | cp 1 97 | jp z, .loadPiece_Square 98 | 99 | cp 2 100 | jp z, .loadPiece_I 101 | 102 | cp 3 103 | jp z, .loadPiece_L 104 | 105 | cp 4 106 | jp z, .loadPiece_J 107 | 108 | cp 5 109 | jp z, .loadPiece_T 110 | 111 | cp 6 112 | jp z, .loadPiece_Z 113 | 114 | cp 7 115 | jp z, .loadPiece_S 116 | 117 | ; ; else 118 | ; jp .loadPiece_I 119 | 120 | ret 121 | 122 | .loadPiece_Square: 123 | ld c, TETRA_CONSTANTS.PIECE_TYPE_SQUARE 124 | ld hl, Tetra_Data.PIECE_SQUARE 125 | ld a, (ix + PROCESS_STRUCT_IX.vramStartTile) ; light blue tile 126 | call .LoadPiece 127 | ret 128 | 129 | .loadPiece_I: 130 | ld c, TETRA_CONSTANTS.PIECE_TYPE_I 131 | ld hl, Tetra_Data.PIECE_I 132 | ld a, (ix + PROCESS_STRUCT_IX.vramStartTile) 133 | inc a ; red tile 134 | call .LoadPiece 135 | ret 136 | 137 | .loadPiece_L: 138 | ld c, TETRA_CONSTANTS.PIECE_TYPE_L 139 | ld hl, Tetra_Data.PIECE_L 140 | ld a, (ix + PROCESS_STRUCT_IX.vramStartTile) 141 | add 2 ; yellow tile 142 | call .LoadPiece 143 | ret 144 | 145 | .loadPiece_J: 146 | ld c, TETRA_CONSTANTS.PIECE_TYPE_J 147 | ld hl, Tetra_Data.PIECE_J 148 | ld a, (ix + PROCESS_STRUCT_IX.vramStartTile) 149 | add 3 ; purple tile 150 | call .LoadPiece 151 | ret 152 | 153 | .loadPiece_T: 154 | ld c, TETRA_CONSTANTS.PIECE_TYPE_T 155 | ld hl, Tetra_Data.PIECE_T 156 | ld a, (ix + PROCESS_STRUCT_IX.vramStartTile) 157 | add 4 ; gray tile 158 | call .LoadPiece 159 | ret 160 | 161 | .loadPiece_Z: 162 | ld c, TETRA_CONSTANTS.PIECE_TYPE_Z 163 | ld hl, Tetra_Data.PIECE_Z 164 | ld a, (ix + PROCESS_STRUCT_IX.vramStartTile) 165 | add 5 ; green tile 166 | call .LoadPiece 167 | ret 168 | 169 | .loadPiece_S: 170 | ld c, TETRA_CONSTANTS.PIECE_TYPE_S 171 | ld hl, Tetra_Data.PIECE_S 172 | ld a, (ix + PROCESS_STRUCT_IX.vramStartTile) 173 | add 6 ; blue tile 174 | call .LoadPiece 175 | ret 176 | 177 | 178 | 179 | ; --------- 180 | 181 | ; Inputs: 182 | ; C: piece type number 183 | ; HL: addr of 4x4 matrix with piece 184 | ; A: tile number 185 | .LoadPiece: 186 | 187 | ; clear current piece 188 | push hl, bc, iy 189 | ; HL = TETRA_VARS.CURRENT_PIECE_TEMP 190 | push iy 191 | pop hl 192 | ld de, TETRA_VARS.CURRENT_PIECE_TEMP 193 | add hl, de 194 | 195 | ld c, 0 196 | ld b, 16 197 | .LoadPiece_loop: 198 | ld (iy + TETRA_VARS.CURRENT_PIECE), c 199 | ld (hl), c 200 | inc iy 201 | inc hl 202 | djnz .LoadPiece_loop 203 | pop iy, bc, hl 204 | 205 | ld (iy + TETRA_VARS.CURRENT_PIECE_TYPE), c 206 | ld c, a 207 | 208 | push hl 209 | push iy ; DE = IY + TETRA_VARS.CURRENT_PIECE 210 | pop hl 211 | ld de, TETRA_VARS.CURRENT_PIECE 212 | add hl, de 213 | ex de, hl 214 | pop hl 215 | 216 | ld b, 16 217 | .loop: 218 | ld a, (hl) 219 | or a 220 | jp z, .next 221 | 222 | ; jp nz, .setTile 223 | 224 | ; ; set empty tile 225 | ; ; xor a 226 | ; jp .next 227 | 228 | ; .setTile: 229 | ld a, c 230 | 231 | .next: 232 | ld (de), a 233 | inc hl 234 | inc de 235 | djnz .loop 236 | 237 | 238 | ; init piece vars 239 | ld a, 2 240 | ld (iy + TETRA_VARS.PIECE_X), a 241 | 242 | ld a, 0 243 | ld (iy + TETRA_VARS.PIECE_Y), a 244 | 245 | ret -------------------------------------------------------------------------------- /Graphics/Sprites.s: -------------------------------------------------------------------------------- 1 | SPRITE_PATTERNS: 2 | 3 | SPRITE_CURSOR_ARROW_PATTERN: 4 | 5 | SPRITE_INDEX_CURSOR_0: equ 0 * 4 6 | ; --- mouse cursor sprite 7 | ; color 1 8 | DB 10000000b 9 | DB 11000000b 10 | DB 10100000b 11 | DB 10010000b 12 | DB 10001000b 13 | DB 10000100b 14 | DB 10000010b 15 | DB 10000001b 16 | DB 10000000b 17 | DB 10000000b 18 | DB 10000011b 19 | DB 10010010b 20 | DB 10101001b 21 | DB 11001001b 22 | DB 00000110b 23 | DB 00000000b 24 | DB 00000000b 25 | DB 00000000b 26 | DB 00000000b 27 | DB 00000000b 28 | DB 00000000b 29 | DB 00000000b 30 | DB 00000000b 31 | DB 00000000b 32 | DB 10000000b 33 | DB 01000000b 34 | DB 11000000b 35 | DB 00000000b 36 | DB 00000000b 37 | DB 00000000b 38 | DB 00000000b 39 | DB 00000000b 40 | SPRITE_INDEX_CURSOR_1: equ 1 * 4 41 | ; color 15 42 | DB 00000000b 43 | DB 00000000b 44 | DB 01000000b 45 | DB 01100000b 46 | DB 01110000b 47 | DB 01111000b 48 | DB 01111100b 49 | DB 01111110b 50 | DB 01111111b 51 | DB 01111111b 52 | DB 01111100b 53 | DB 01101100b 54 | DB 01000110b 55 | DB 00000110b 56 | DB 00000000b 57 | DB 00000000b 58 | DB 00000000b 59 | DB 00000000b 60 | DB 00000000b 61 | DB 00000000b 62 | DB 00000000b 63 | DB 00000000b 64 | DB 00000000b 65 | DB 00000000b 66 | DB 00000000b 67 | DB 10000000b 68 | DB 00000000b 69 | DB 00000000b 70 | DB 00000000b 71 | DB 00000000b 72 | DB 00000000b 73 | DB 00000000b 74 | SPRITE_CURSOR_ARROW_PATTERN.size: equ $ - SPRITE_CURSOR_ARROW_PATTERN 75 | 76 | SPRITE_INDEX_WINDOW_TOP_LEFT: equ 2 * 4 77 | DB 11001100 b 78 | DB 10000000 b 79 | DB 00000000 b 80 | DB 00000000 b 81 | DB 10000000 b 82 | DB 10000000 b 83 | DB 00000000 b 84 | DB 00000000 b 85 | 86 | DB 10000000 b 87 | DB 10000000 b 88 | DB 00000000 b 89 | DB 00000000 b 90 | DB 10000000 b 91 | DB 10000000 b 92 | DB 00000000 b 93 | DB 00000000 b 94 | 95 | DB 11001100 b 96 | DB 00000000 b 97 | DB 00000000 b 98 | DB 00000000 b 99 | DB 00000000 b 100 | DB 00000000 b 101 | DB 00000000 b 102 | DB 00000000 b 103 | 104 | DB 00000000 b 105 | DB 00000000 b 106 | DB 00000000 b 107 | DB 00000000 b 108 | DB 00000000 b 109 | DB 00000000 b 110 | DB 00000000 b 111 | DB 00000000 b 112 | 113 | SPRITE_INDEX_WINDOW_TOP_RIGHT: equ 3 * 4 114 | DB 11001100 b 115 | DB 00000000 b 116 | DB 00000000 b 117 | DB 00000000 b 118 | DB 00000000 b 119 | DB 00000000 b 120 | DB 00000000 b 121 | DB 00000000 b 122 | 123 | DB 00000000 b 124 | DB 00000000 b 125 | DB 00000000 b 126 | DB 00000000 b 127 | DB 00000000 b 128 | DB 00000000 b 129 | DB 00000000 b 130 | DB 00000000 b 131 | 132 | DB 00110011 b 133 | DB 00000001 b 134 | DB 00000000 b 135 | DB 00000000 b 136 | DB 00000001 b 137 | DB 00000001 b 138 | DB 00000000 b 139 | DB 00000000 b 140 | 141 | DB 00000001 b 142 | DB 00000001 b 143 | DB 00000000 b 144 | DB 00000000 b 145 | DB 00000001 b 146 | DB 00000001 b 147 | DB 00000000 b 148 | DB 00000000 b 149 | 150 | SPRITE_INDEX_WINDOW_BOTTOM_LEFT: equ 4 * 4 151 | DB 00000000 b 152 | DB 00000000 b 153 | DB 10000000 b 154 | DB 10000000 b 155 | DB 00000000 b 156 | DB 00000000 b 157 | DB 10000000 b 158 | DB 10000000 b 159 | 160 | DB 00000000 b 161 | DB 00000000 b 162 | DB 10000000 b 163 | DB 10000000 b 164 | DB 00000000 b 165 | DB 00000000 b 166 | DB 10000000 b 167 | DB 11001100 b 168 | 169 | DB 00000000 b 170 | DB 00000000 b 171 | DB 00000000 b 172 | DB 00000000 b 173 | DB 00000000 b 174 | DB 00000000 b 175 | DB 00000000 b 176 | DB 00000000 b 177 | 178 | DB 00000000 b 179 | DB 00000000 b 180 | DB 00000000 b 181 | DB 00000000 b 182 | DB 00000000 b 183 | DB 00000000 b 184 | DB 00000000 b 185 | DB 11001100 b 186 | 187 | SPRITE_INDEX_WINDOW_BOTTOM_RIGHT: equ 5 * 4 188 | DB 00000000 b 189 | DB 00000000 b 190 | DB 00000000 b 191 | DB 00000000 b 192 | DB 00000000 b 193 | DB 00000000 b 194 | DB 00000000 b 195 | DB 00000000 b 196 | 197 | DB 00000000 b 198 | DB 00000000 b 199 | DB 00000000 b 200 | DB 00000000 b 201 | DB 00000000 b 202 | DB 00000000 b 203 | DB 00000000 b 204 | DB 00110011 b 205 | 206 | DB 00000000 b 207 | DB 00000000 b 208 | DB 00000001 b 209 | DB 00000001 b 210 | DB 00000000 b 211 | DB 00000000 b 212 | DB 00000001 b 213 | DB 00000001 b 214 | 215 | DB 00000000 b 216 | DB 00000000 b 217 | DB 00000001 b 218 | DB 00000001 b 219 | DB 00000000 b 220 | DB 00000000 b 221 | DB 00000001 b 222 | DB 00110011 b 223 | 224 | SPRITE_PATTERNS.size: equ $ - SPRITE_PATTERNS 225 | 226 | 227 | 228 | SPRITE_CURSOR_RESIZE_PATTERN: 229 | ; color 1 230 | DB 11111110b 231 | DB 10000100b 232 | DB 10001000b 233 | DB 10000100b 234 | DB 10100010b 235 | DB 11010001b 236 | DB 10001000b 237 | DB 00000100b 238 | DB 00000010b 239 | DB 00000001b 240 | DB 00000000b 241 | DB 00000000b 242 | DB 00000000b 243 | DB 00000000b 244 | DB 00000000b 245 | DB 00000000b 246 | DB 00000000b 247 | DB 00000000b 248 | DB 00000000b 249 | DB 00000000b 250 | DB 00000000b 251 | DB 00000000b 252 | DB 10000000b 253 | DB 01000000b 254 | DB 00100000b 255 | DB 00010001b 256 | DB 10001011b 257 | DB 01000101b 258 | DB 00100001b 259 | DB 00010001b 260 | DB 00100001b 261 | DB 01111111b 262 | ; color 15 263 | DB 00000000b 264 | DB 01111000b 265 | DB 01110000b 266 | DB 01111000b 267 | DB 01011100b 268 | DB 00001110b 269 | DB 00000111b 270 | DB 00000011b 271 | DB 00000001b 272 | DB 00000000b 273 | DB 00000000b 274 | DB 00000000b 275 | DB 00000000b 276 | DB 00000000b 277 | DB 00000000b 278 | DB 00000000b 279 | DB 00000000b 280 | DB 00000000b 281 | DB 00000000b 282 | DB 00000000b 283 | DB 00000000b 284 | DB 00000000b 285 | DB 00000000b 286 | DB 10000000b 287 | DB 11000000b 288 | DB 11100000b 289 | DB 01110000b 290 | DB 00111010b 291 | DB 00011110b 292 | DB 00001110b 293 | DB 00011110b 294 | DB 00000000b 295 | .size: equ $ - SPRITE_CURSOR_RESIZE_PATTERN -------------------------------------------------------------------------------- /System/Process/LoadProcess.s: -------------------------------------------------------------------------------- 1 | ; Input: 2 | ; HL = addr of process header (on ROM) 3 | _LOAD_PROCESS: 4 | 5 | ; if ((OS.nextAvailableProcessAddr) == 0xffff) alert('Max process limit exceeded') 6 | ld de, (OS.nextAvailableProcessAddr) 7 | ld a, 0xff 8 | cp d 9 | jp nz, .skip_0 10 | cp e 11 | jp z, .showAlertMaxProcessLimitReached 12 | .skip_0: 13 | 14 | ; clear this process slot (fill with 0xff) 15 | push hl 16 | ld a, 0xff 17 | ld hl, (OS.nextAvailableProcessAddr) 18 | ld (hl), a 19 | 20 | push hl ; DE = HL 21 | pop de 22 | 23 | inc de 24 | 25 | ; ld hl, ? 26 | ; ld de, ? 27 | ld bc, Process_struct.size - 1 28 | ldir 29 | pop hl 30 | 31 | 32 | ; copy header from source to next empty process slot 33 | ;ld hl, ??? ; source 34 | ld de, (OS.nextAvailableProcessAddr) ; destiny 35 | ld bc, Process_struct.size_Header ; size 36 | ldir ; Copy BC bytes from HL to DE 37 | 38 | ; set current process to this 39 | ld hl, (OS.nextAvailableProcessAddr) 40 | ld (OS.currentProcessAddr), hl 41 | 42 | 43 | 44 | ; set processId 45 | ld hl, (OS.currentProcessAddr) 46 | call _GET_NEXT_AVAILABLE_PROCESS_ID 47 | ld a, ixh 48 | cp 255 49 | jp z, .maxProcessLimitReached 50 | ld hl, (OS.currentProcessAddr) 51 | ld (hl), a ; set ProcessId 52 | 53 | ; update next empty process slot to the next 54 | call _GET_NEXT_AVAILABLE_PROCESS_ADDR 55 | ; inc a ; if (A == 255) .maxProcessLimitReached 56 | ; jp z, .maxProcessLimitReached 57 | ld (OS.nextAvailableProcessAddr), hl 58 | 59 | 60 | 61 | ld ix, (OS.currentProcessAddr) 62 | 63 | ; define ramStartAddr and vramStartTile 64 | push ix ; HL = IX 65 | pop hl 66 | 67 | ld de, OS.process_slot_0 68 | call BIOS_DCOMPR 69 | jp z, .isOnProcessSlot_0 70 | 71 | ld de, OS.process_slot_1 72 | call BIOS_DCOMPR 73 | jp z, .isOnProcessSlot_1 74 | 75 | ld de, OS.process_slot_2 76 | call BIOS_DCOMPR 77 | jp z, .isOnProcessSlot_2 78 | 79 | ld de, OS.process_slot_3 80 | call BIOS_DCOMPR 81 | jp z, .isOnProcessSlot_3 82 | 83 | jp .cont_1001 84 | 85 | .isOnProcessSlot_0: 86 | ld hl, OS.processesVariablesArea_0 87 | ld a, TILE_BASE_INDEX_PROCESS_0 88 | jp .saveRamStartAddr 89 | 90 | .isOnProcessSlot_1: 91 | ld hl, OS.processesVariablesArea_1 92 | ld a, TILE_BASE_INDEX_PROCESS_1 93 | jp .saveRamStartAddr 94 | 95 | .isOnProcessSlot_2: 96 | ld hl, OS.processesVariablesArea_2 97 | ld a, TILE_BASE_INDEX_PROCESS_2 98 | jp .saveRamStartAddr 99 | 100 | .isOnProcessSlot_3: 101 | ld hl, OS.processesVariablesArea_3 102 | ld a, TILE_BASE_INDEX_PROCESS_3 103 | ; jp .saveRamStartAddr 104 | 105 | .saveRamStartAddr: 106 | ld (ix + PROCESS_STRUCT_IX.ramStartAddr), l 107 | ld (ix + PROCESS_STRUCT_IX.ramStartAddr + 1), h 108 | ld (ix + PROCESS_STRUCT_IX.vramStartTile), a 109 | 110 | .cont_1001: 111 | 112 | ; get number of current processes and make it the layer number (0-3) 113 | call _GET_NUMBER_OF_PROCESSES_OPENED 114 | dec a 115 | ld (ix + PROCESS_STRUCT_IX.layer), a 116 | 117 | ld a, WINDOW_STATE.RESTORED 118 | ld (ix + PROCESS_STRUCT_IX.previousWindowState), a 119 | 120 | ; --- set x and y of window and 121 | ; --- update OS.nextWindow_x and y to the next 122 | ld a, (OS.nextWindow_x) 123 | ; if (OS.nextWindow_x + process.width > 32) process.x = 0 124 | ld b, (ix + PROCESS_STRUCT_IX.width) 125 | add b 126 | cp 32 + 1 127 | jp nc, .fixWidth 128 | ld a, (OS.nextWindow_x) 129 | jp .cont_200 130 | .fixWidth: 131 | xor a 132 | .cont_200: 133 | ld (ix + PROCESS_STRUCT_IX.x), a 134 | add 2 135 | ld (OS.nextWindow_x), a 136 | 137 | ld a, (OS.nextWindow_y) 138 | ; if (OS.nextWindow_y + process.height > 22) process.y = 0 139 | ld b, (ix + PROCESS_STRUCT_IX.height) 140 | add b 141 | cp 22 + 1 142 | jp nc, .fixHeight 143 | ld a, (OS.nextWindow_y) 144 | jp .cont_100 145 | .fixHeight: 146 | xor a 147 | .cont_100: 148 | ld (ix + PROCESS_STRUCT_IX.y), a 149 | add 2 150 | ld (OS.nextWindow_y), a 151 | cp 8 152 | call nc, .resetNextWindow_XY ; if (A >= 8) .resetNextWindow_XY 153 | 154 | 155 | ; get RAM variables area of this process 156 | ld l, (ix + PROCESS_STRUCT_IX.ramStartAddr) 157 | ld h, (ix + PROCESS_STRUCT_IX.ramStartAddr + 1) 158 | 159 | push hl ; IY = HL 160 | pop iy 161 | 162 | ; call process "Open" event 163 | ; ld hl, (OS.currentProcessAddr) 164 | ld ix, (OS.currentProcessAddr) 165 | ld e, (ix + PROCESS_STRUCT_IX.openAddr) ; process.Open addr (low) 166 | ld d, (ix + PROCESS_STRUCT_IX.openAddr + 1) ; process.Open addr (high) 167 | call JP_DE 168 | 169 | 170 | 171 | call _UPDATE_SCREEN 172 | 173 | 174 | call _DRAW_TASKBAR 175 | 176 | 177 | 178 | ; ld l, (ix + n) ; process.Open addr 179 | ; ld h, (ix + n + 1) ; process.Open addr + 1 180 | ; ; simulate call (hl) 181 | ; push hl 182 | ; jp (hl) 183 | 184 | ; other method to emulate call (hl): 185 | 186 | ; ; Simply "jp [hl]", but can be used to emulate the instruction "call [hl]" 187 | ; ; param hl: address 188 | ; JP_HL: 189 | ; jp [hl] 190 | 191 | 192 | 193 | ret 194 | 195 | .maxProcessLimitReached: 196 | ; set nextAvailableProcessAddr to 0xffff, meaning no memory space available for new process 197 | ld hl, 0xffff 198 | ld (OS.nextAvailableProcessAddr), hl 199 | 200 | ret 201 | 202 | .showAlertMaxProcessLimitReached: 203 | 204 | ; debug 205 | ; call BIOS_BEEP 206 | ; jp .showAlertMaxProcessLimitReached 207 | 208 | ret 209 | 210 | .resetNextWindow_XY: 211 | xor a 212 | ld (OS.nextWindow_x), a 213 | ld (OS.nextWindow_y), a 214 | 215 | ret 216 | 217 | -------------------------------------------------------------------------------- /Apps/Tetra/Draw.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | 6 | 7 | ; ; draw empty playfield 8 | ; ld hl, Tetra_Data.PLAYFIELD_TILES ; RAM address (source) 9 | ; ld b, 10 ; size of line 10 | ; ld c, 20 ; number of lines 11 | ; call DRAW_ON_WINDOW_USEFUL_AREA 12 | 13 | ; --- copy from playfield to playfield buffer 14 | 15 | ; set DE to destiny 16 | ld de, TETRA_VARS.PLAYFIELD_BUFFER 17 | push iy ; HL = IY 18 | pop hl 19 | add hl, de 20 | push hl 21 | 22 | ; set HL to source 23 | ld de, TETRA_VARS.PLAYFIELD 24 | push iy ; HL = IY 25 | pop hl 26 | add hl, de 27 | pop de 28 | 29 | ld bc, TETRA_CONSTANTS.PLAYFIELD_WIDTH * TETRA_CONSTANTS.PLAYFIELD_HEIGHT 30 | ldir 31 | 32 | 33 | 34 | ; ---- draw current piece on playfield buffer 35 | 36 | call .ConvertPiece_XY_ToLinear 37 | 38 | ; HL += PLAYFIELD_BUFFER 39 | push hl 40 | ld de, TETRA_VARS.PLAYFIELD_BUFFER 41 | push iy ; HL = IY 42 | pop hl 43 | add hl, de 44 | pop de 45 | add hl, de 46 | 47 | 48 | call .PutPieceIntoPlayfield 49 | 50 | 51 | 52 | ; draw playfield on screen from playfield buffer 53 | ld de, TETRA_VARS.PLAYFIELD_BUFFER 54 | push iy ; HL = IY 55 | pop hl 56 | add hl, de 57 | ex de, hl 58 | 59 | push de 60 | call GET_USEFUL_WINDOW_BASE_NAMTBL 61 | ld de, 32 62 | add hl, de 63 | pop de 64 | 65 | 66 | ld c, TETRA_CONSTANTS.PLAYFIELD_HEIGHT ; number of lines 67 | .outerLoop_1: 68 | call BIOS_SETWRT 69 | 70 | push hl 71 | ld b, TETRA_CONSTANTS.PLAYFIELD_WIDTH ; size of line 72 | .loop_1: 73 | ld a, (de) 74 | or a 75 | jr nz, .drawPlayfield_cont 76 | 77 | ld a, TILE_EMPTY_BLACK 78 | .drawPlayfield_cont: 79 | out (PORT_0), a 80 | inc de 81 | djnz .loop_1 82 | pop hl 83 | 84 | ; HL += 32 85 | push de 86 | ld de, 32 87 | add hl, de 88 | pop de 89 | 90 | dec c 91 | jp nz, .outerLoop_1 92 | 93 | 94 | 95 | ret 96 | 97 | ; Input: 98 | ; HL = piece linear position on playfield (it can be either PLAYFIELD or PLAYFIELD_BUFFER) 99 | .PutPieceIntoPlayfield: 100 | ;push hl 101 | ld a, (iy + TETRA_VARS.CURRENT_PIECE) 102 | call .drawPieceTile 103 | 104 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 1) 105 | call .drawPieceTile 106 | 107 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 2) 108 | call .drawPieceTile 109 | 110 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 3) 111 | call .drawPieceTile 112 | ;pop hl 113 | 114 | ld de, TETRA_CONSTANTS.PLAYFIELD_WIDTH - 4 ; next line 115 | add hl, de 116 | 117 | ; push hl 118 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 4) 119 | call .drawPieceTile 120 | 121 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 5) 122 | call .drawPieceTile 123 | 124 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 6) 125 | call .drawPieceTile 126 | 127 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 7) 128 | call .drawPieceTile 129 | ; pop hl 130 | 131 | ld de, TETRA_CONSTANTS.PLAYFIELD_WIDTH - 4 ; next line 132 | add hl, de 133 | 134 | ; push hl 135 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 8) 136 | call .drawPieceTile 137 | 138 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 9) 139 | call .drawPieceTile 140 | 141 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 10) 142 | call .drawPieceTile 143 | 144 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 11) 145 | call .drawPieceTile 146 | ; pop hl 147 | 148 | ld de, TETRA_CONSTANTS.PLAYFIELD_WIDTH - 4 ; next line 149 | add hl, de 150 | 151 | ; push hl 152 | ; call BIOS_SETWRT 153 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 12) 154 | call .drawPieceTile 155 | 156 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 13) 157 | call .drawPieceTile 158 | 159 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 14) 160 | call .drawPieceTile 161 | 162 | ld a, (iy + TETRA_VARS.CURRENT_PIECE + 15) 163 | call .drawPieceTile 164 | ; pop hl 165 | 166 | ret 167 | 168 | .drawPieceTile: 169 | or a 170 | jr z, .drawPieceTile_ignore 171 | 172 | .drawPieceTile_cont: 173 | ld (hl), a 174 | .drawPieceTile_ignore: 175 | inc hl 176 | ret 177 | 178 | ; ------ 179 | 180 | ; Convert real X,Y of piece into linear addr on playfield 181 | ; Input: 182 | ; IY should point to process vars addr 183 | ; Output: 184 | ; HL: linear addr of piece on playfield 185 | .ConvertPiece_XY_ToLinear: 186 | 187 | ; adjust y position 188 | ; HL = PIECE_Y * PLAYFIELD_WIDTH 189 | ld hl, 0 190 | ld de, TETRA_CONSTANTS.PLAYFIELD_WIDTH 191 | ld a, (iy + TETRA_VARS.PIECE_Y) 192 | or a 193 | jp z, .ConvertPiece_XY_ToLinear_skip_Mult 194 | ld b, a 195 | .ConvertPiece_XY_ToLinear_loop_Mult: 196 | add hl, de 197 | djnz .ConvertPiece_XY_ToLinear_loop_Mult 198 | .ConvertPiece_XY_ToLinear_skip_Mult: 199 | 200 | ; adjust x position 201 | ld d, 0 202 | ld e, (iy + TETRA_VARS.PIECE_X) 203 | add hl, de 204 | 205 | ret 206 | 207 | 208 | 209 | ; Convert X,Y of piece passed by parameters into linear addr on playfield 210 | ; Input: 211 | ; D: piece x 212 | ; E: piece y 213 | ; Output: 214 | ; HL: linear addr of piece on playfield 215 | .ConvertPiece_DE_ToLinear: 216 | 217 | ld a, d 218 | ld (OS.tempVar_1), a ; x 219 | 220 | ld a, e 221 | ld (OS.tempVar_2), a ; y 222 | 223 | ; adjust y position 224 | ; HL = PIECE_Y * PLAYFIELD_WIDTH 225 | ld hl, 0 226 | ld de, TETRA_CONSTANTS.PLAYFIELD_WIDTH 227 | ld a, (OS.tempVar_2) 228 | or a 229 | jp z, .ConvertPiece_DE_ToLinear_skip_Mult 230 | ld b, a 231 | .ConvertPiece_DE_ToLinear_loop_Mult: 232 | add hl, de 233 | djnz .ConvertPiece_DE_ToLinear_loop_Mult 234 | .ConvertPiece_DE_ToLinear_skip_Mult: 235 | 236 | ; adjust x position 237 | ld d, 0 238 | ld a, (OS.tempVar_1) 239 | ld e, a 240 | add hl, de 241 | 242 | ret -------------------------------------------------------------------------------- /System/Desktop/Taskbar.s: -------------------------------------------------------------------------------- 1 | ; taskbar: 2 | ; 5 tiles at left (home, show desktop, plus spaces) 3 | ; 7 tiles at right (hh:mm + spaces) 4 | ; 5 | ; = 20 tiles for buttons 6 | ; 5 per button: 4 for name, plus 1 for separator 7 | 8 | ; Input: nothing 9 | ; Output: nothing 10 | _DRAW_TASKBAR: 11 | 12 | ; draw taskbar 13 | ld hl, TASKBAR_INIT ; RAM address (source) 14 | ld de, NAMTBL + (32 * 22) ; VRAM address (destiny) 15 | ld bc, 64 ; Block length 16 | call BIOS_LDIRVM ; Block transfer to VRAM from memory 17 | 18 | 19 | 20 | call _DRAW_TASKBAR_BUTTONS 21 | 22 | 23 | call _DRAW_TASKBAR_CLOCK 24 | 25 | 26 | ret 27 | 28 | 29 | 30 | _DRAW_TASKBAR_BUTTONS: 31 | 32 | ld iy, NAMTBL + (32 * 23) + 5 33 | 34 | ; init taskbar_Button_?_Process_addr vars 35 | ld hl, 0xffff 36 | ld (OS.taskbar_Button_0_Process_addr), hl 37 | ld (OS.taskbar_Button_1_Process_addr), hl 38 | ld (OS.taskbar_Button_2_Process_addr), hl 39 | ld (OS.taskbar_Button_3_Process_addr), hl 40 | 41 | ld hl, OS.taskbar_Button_0_Process_addr 42 | ld (OS.tempWord), hl 43 | 44 | ; loop through process slots drawing taskbar buttons 45 | ld hl, OS.processes 46 | ld b, MAX_PROCESS_ID + 1 47 | .loop_1: 48 | ld a, (hl) 49 | inc a 50 | jp z, .next ; if (process id == 255) next 51 | 52 | ; TILE_FONT_REVERSED_LOWERCASE_A = 01Eh = 30 53 | ; TILE_FONT_LOWERCASE_A = 043h = 67 54 | 55 | push hl ; IX = HL 56 | pop ix 57 | 58 | ; link process addr to button for click 59 | push de 60 | ld de, (OS.tempWord) 61 | 62 | ld a, l 63 | ld (de), a 64 | inc de 65 | ld a, h 66 | ld (de), a 67 | inc de 68 | 69 | ld (OS.tempWord), de 70 | pop de 71 | 72 | push hl, bc 73 | 74 | ld bc, PROCESS_STRUCT_IX.taskbarTitle 75 | add hl, bc 76 | 77 | push hl ; DE = HL 78 | pop de 79 | 80 | push iy ; HL = IY 81 | pop hl 82 | call BIOS_SETWRT 83 | 84 | ld c, 4 ; max size of title on button 85 | 86 | .loop_2: 87 | ; ld a, (de) 88 | ; cp TILE_EMPTY_BLACK 89 | ; jp z, .end_1 90 | 91 | push de 92 | 93 | ld de, (OS.currentProcessAddr) 94 | 95 | push ix ; HL = IX 96 | pop hl 97 | 98 | call BIOS_DCOMPR 99 | 100 | pop de 101 | 102 | jp nz, .printNormal 103 | 104 | ; print black chars on white bg 105 | ld a, (de) 106 | 107 | cp TILE_EMPTY_BLACK 108 | jp z, .printTileWhite 109 | 110 | add TILE_FONT_LOWERCASE_A - TILE_FONT_REVERSED_LOWERCASE_A 111 | jp .continue_2 112 | 113 | .printTileWhite: 114 | ld a, TILE_EMPTY 115 | jp .continue_2 116 | 117 | .printNormal: 118 | ld a, (de) 119 | .continue_2: 120 | out (PORT_0), a 121 | 122 | dec c 123 | jp z, .end_1 124 | 125 | inc de 126 | jp .loop_2 127 | 128 | .end_1: 129 | 130 | ld bc, 5 131 | add iy, bc ; go to next button 132 | 133 | pop bc, hl 134 | 135 | 136 | 137 | .next: 138 | ld de, Process_struct.size 139 | add hl, de 140 | 141 | djnz .loop_1 142 | 143 | ret 144 | 145 | 146 | 147 | ; draw system time on right of taskbar 148 | _DRAW_TASKBAR_CLOCK: 149 | 150 | ; set HL to clock place on taskbar 151 | ld hl, NAMTBL + (32 * 23) + 26 ; VRAM address (destiny) 152 | call BIOS_SETWRT 153 | ld c, PORT_0 154 | 155 | 156 | ld b, TILE_FONT_REVERSED_NUMBERS_0 157 | 158 | ; tens of hours digit 159 | ld a, (OS.currentTime_Hours) 160 | srl a ; shift right n, bit 7 = 0, carry = 0 161 | srl a ; shift right n, bit 7 = 0, carry = 0 162 | srl a ; shift right n, bit 7 = 0, carry = 0 163 | srl a ; shift right n, bit 7 = 0, carry = 0 164 | or a 165 | jp z, .skipTensOfHours ; if tens of hours == 0 not print 166 | add b ; convert digit in BCD to tile number 167 | jp .continue 168 | .skipTensOfHours: 169 | ld a, TILE_EMPTY_BLACK 170 | .continue: 171 | out (c), a 172 | 173 | ; units of hours digit 174 | ld a, (OS.currentTime_Hours) 175 | and 0000 1111 b 176 | add b ; convert digit in BCD to tile number 177 | out (c), a 178 | 179 | ; write char ':' 180 | nop 181 | nop 182 | ld a, TILE_FONT_REVERSED_SYMBOLS + 0 ; char ':' 183 | out (c), a 184 | 185 | ; tens of minutes digit 186 | ld a, (OS.currentTime_Minutes) 187 | srl a ; shift right n, bit 7 = 0, carry = 0 188 | srl a ; shift right n, bit 7 = 0, carry = 0 189 | srl a ; shift right n, bit 7 = 0, carry = 0 190 | srl a ; shift right n, bit 7 = 0, carry = 0 191 | add b ; convert digit in BCD to tile number 192 | out (c), a 193 | 194 | ; units of minutes digit 195 | ld a, (OS.currentTime_Minutes) 196 | and 0000 1111 b 197 | add b ; convert digit in BCD to tile number 198 | out (c), a 199 | 200 | ret 201 | 202 | 203 | 204 | TASKBAR_INIT: 205 | ; first line 206 | db TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP 207 | db TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP 208 | db TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP 209 | db TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP 210 | db TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP 211 | db TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP 212 | db TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP 213 | db TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP, TILE_TASKBAR_TOP 214 | 215 | ; second line 216 | db TILE_EMPTY_BLACK, TILE_HOME_ICON, TILE_EMPTY_BLACK 217 | 218 | db TILE_SHOW_DESKTOP_ICON, TILE_EMPTY_BLACK 219 | 220 | db TILE_EMPTY_BLACK 221 | db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 222 | db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 223 | 224 | db TILE_EMPTY_BLACK 225 | 226 | db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 227 | 228 | db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 229 | db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 230 | 231 | db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 232 | 233 | db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 234 | 235 | db TILE_EMPTY_BLACK 236 | -------------------------------------------------------------------------------- /Apps/Tetra/Data.s: -------------------------------------------------------------------------------- 1 | 2 | ; .PLAYFIELD_TILES: 3 | 4 | ; db TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY, TILE_EMPTY 5 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 6 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 7 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 8 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 9 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 10 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 11 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 12 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 13 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 14 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 15 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 16 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 17 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 18 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 19 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 20 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 21 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 22 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 23 | ; db TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK, TILE_EMPTY_BLACK 24 | 25 | .TILE_pattern: 26 | db 00000000 b 27 | db 01111111 b 28 | db 01111111 b 29 | db 01111111 b 30 | db 01111111 b 31 | db 01111111 b 32 | db 01111111 b 33 | db 01111111 b 34 | 35 | .TILE_LIGHT_BLUE_colors: 36 | db 0x7f 37 | db 0x7f 38 | db 0x7f 39 | db 0x7f 40 | db 0x7f 41 | db 0x7f 42 | db 0x7f 43 | db 0x7f 44 | 45 | .TILE_RED_colors: 46 | db 0x8f 47 | db 0x8f 48 | db 0x8f 49 | db 0x8f 50 | db 0x8f 51 | db 0x8f 52 | db 0x8f 53 | db 0x8f 54 | 55 | .TILE_YELLOW_colors: 56 | db 0xaf 57 | db 0xaf 58 | db 0xaf 59 | db 0xaf 60 | db 0xaf 61 | db 0xaf 62 | db 0xaf 63 | db 0xaf 64 | 65 | .TILE_PURPLE_colors: 66 | db 0xdf 67 | db 0xdf 68 | db 0xdf 69 | db 0xdf 70 | db 0xdf 71 | db 0xdf 72 | db 0xdf 73 | db 0xdf 74 | 75 | .TILE_GRAY_colors: 76 | db 0xef 77 | db 0xef 78 | db 0xef 79 | db 0xef 80 | db 0xef 81 | db 0xef 82 | db 0xef 83 | db 0xef 84 | 85 | .TILE_GREEN_colors: 86 | db 0xcf 87 | db 0xcf 88 | db 0xcf 89 | db 0xcf 90 | db 0xcf 91 | db 0xcf 92 | db 0xcf 93 | db 0xcf 94 | 95 | .TILE_BLUE_colors: 96 | db 0x4f 97 | db 0x4f 98 | db 0x4f 99 | db 0x4f 100 | db 0x4f 101 | db 0x4f 102 | db 0x4f 103 | db 0x4f 104 | 105 | ; ------------- 106 | 107 | .PIECE_SQUARE: ; light blue 108 | db 1, 1, 0, 0 109 | db 1, 1, 0, 0 110 | db 0, 0, 0, 0 111 | db 0, 0, 0, 0 112 | 113 | .PIECE_I: ; red 114 | db 1, 0, 0, 0 115 | db 1, 0, 0, 0 116 | db 1, 0, 0, 0 117 | db 1, 0, 0, 0 118 | 119 | .PIECE_L: ; yellow 120 | db 1, 0, 0, 0 121 | db 1, 0, 0, 0 122 | db 1, 1, 0, 0 123 | db 0, 0, 0, 0 124 | 125 | .PIECE_J: ; purple 126 | db 0, 1, 0, 0 127 | db 0, 1, 0, 0 128 | db 1, 1, 0, 0 129 | db 0, 0, 0, 0 130 | 131 | .PIECE_T: ; gray 132 | db 0, 1, 0, 0 133 | db 1, 1, 1, 0 134 | db 0, 0, 0, 0 135 | db 0, 0, 0, 0 136 | 137 | .PIECE_Z: ; green 138 | db 0, 1, 0, 0 139 | db 1, 1, 0, 0 140 | db 1, 0, 0, 0 141 | db 0, 0, 0, 0 142 | 143 | .PIECE_S: ; blue 144 | db 1, 0, 0, 0 145 | db 1, 1, 0, 0 146 | db 0, 1, 0, 0 147 | db 0, 0, 0, 0 148 | 149 | 150 | ; ------------------------- 151 | 152 | TETRA_VARS: 153 | .CURRENT_PIECE: equ 0 ; 4 * 4 = 16 bytes 154 | .PIECE_X: equ 16 ; 1 byte 155 | .PIECE_Y: equ 17 ; 1 byte 156 | .OLD_KEYBOARD_LINE_8: equ 18 ; 1 byte 157 | .COUNTER: equ 19 ; 1 byte 158 | .CURRENT_PIECE_TYPE: equ 20 ; 1 byte 159 | 160 | ; TODO: wasted space here 161 | 162 | .PLAYFIELD: equ 40 ; 10 * 20 = 200 bytes ; TODO: if TETRA_CONSTANTS.PLAYFIELD_HEIGHT is less than 20, there will be some bytes wasted here 163 | 164 | .PLAYFIELD_BUFFER: equ 240 ; 10 * 20 = 200 bytes 165 | 166 | .CURRENT_PIECE_TEMP: equ 440 ; 4 * 4 = 16 bytes 167 | 168 | ;-------------------------- 169 | 170 | TETRA_CONSTANTS: 171 | .PLAYFIELD_WIDTH: equ 10 172 | .PLAYFIELD_HEIGHT: equ 18 173 | 174 | .PIECE_TYPE_SQUARE: equ 0 175 | .PIECE_TYPE_I: equ 1 176 | .PIECE_TYPE_L: equ 2 177 | .PIECE_TYPE_J: equ 3 178 | .PIECE_TYPE_T: equ 4 179 | .PIECE_TYPE_Z: equ 5 180 | .PIECE_TYPE_S: equ 6 181 | -------------------------------------------------------------------------------- /Apps/Settings/Draw.s: -------------------------------------------------------------------------------- 1 | ; Input 2 | ; IX = base addr of this process slot on RAM 3 | ; IY = base addr of variables area of this process 4 | 5 | call GET_USEFUL_WINDOW_BASE_NAMTBL 6 | 7 | ex de, hl 8 | 9 | ; draw tabs 10 | ld hl, Settings_Data.SETTINGS_TABS ; RAM address (source) 11 | ld b, 18 ; size of line 12 | ld c, 11 ; number of lines 13 | call DRAW_ON_WINDOW_USEFUL_AREA 14 | 15 | 16 | 17 | ld a, (iy + SETTINGS_VARS.TAB_SELECTED) 18 | cp SETTINGS_TABS_VALUES.TAB_VIDEO 19 | jp z, .drawCurrentTabVideo 20 | cp SETTINGS_TABS_VALUES.TAB_MOUSE 21 | jp z, .drawCurrentTabMouse 22 | cp SETTINGS_TABS_VALUES.TAB_TIME 23 | jp z, .drawCurrentTabTime 24 | 25 | 26 | ret 27 | 28 | .drawCurrentTabVideo: 29 | call GET_USEFUL_WINDOW_BASE_NAMTBL 30 | ld de, 32 * 2 ; two lines below 31 | add hl, de 32 | ex de, hl 33 | 34 | ld hl, Settings_Data.CURRENT_TAB_VIDEO_TILES ; RAM address (source) 35 | ld b, 18 ; size of line 36 | ld c, 1 ; number of lines 37 | call DRAW_ON_WINDOW_USEFUL_AREA 38 | 39 | ; --- draw label screen saver 40 | call GET_USEFUL_WINDOW_BASE_NAMTBL 41 | ld de, 1 + (32 * 4) ; 4 lines below, one tile to the right 42 | add hl, de 43 | ex de, hl 44 | 45 | ld hl, Settings_Data.LABEL_COMBO_SCREEN_SAVER ; RAM address (source) 46 | ld b, 12 ; size of line 47 | ld c, 1 ; number of lines 48 | call DRAW_ON_WINDOW_USEFUL_AREA 49 | 50 | 51 | ; --- draw combo screen saver 52 | call GET_USEFUL_WINDOW_BASE_NAMTBL 53 | ld de, 1 + (32 * 5) ; 5 lines below, one tile to the right 54 | add hl, de 55 | ex de, hl 56 | 57 | ld hl, Settings_Data.COMBO_SCREEN_SAVER ; RAM address (source) 58 | ld b, 12 ; size of line 59 | ld c, 3 ; number of lines 60 | call DRAW_ON_WINDOW_USEFUL_AREA 61 | 62 | 63 | ret 64 | 65 | .drawCurrentTabMouse: 66 | call GET_USEFUL_WINDOW_BASE_NAMTBL 67 | ld de, 32 * 2 ; two lines below 68 | add hl, de 69 | ex de, hl 70 | 71 | ld hl, Settings_Data.CURRENT_TAB_MOUSE_TILES ; RAM address (source) 72 | ld b, 18 ; size of line 73 | ld c, 1 ; number of lines 74 | call DRAW_ON_WINDOW_USEFUL_AREA 75 | 76 | ret 77 | 78 | .drawCurrentTabTime: 79 | call GET_USEFUL_WINDOW_BASE_NAMTBL 80 | ld de, 32 * 2 ; two lines below 81 | add hl, de 82 | ex de, hl 83 | 84 | ld hl, Settings_Data.CURRENT_TAB_TIME_TILES ; RAM address (source) 85 | ld b, 18 ; size of line 86 | ld c, 1 ; number of lines 87 | call DRAW_ON_WINDOW_USEFUL_AREA 88 | 89 | 90 | 91 | ; Draw time 92 | call .DrawClock 93 | 94 | 95 | ; --- draw checkbox 96 | call GET_USEFUL_WINDOW_BASE_NAMTBL 97 | ld de, 2 + (32 * 7) ; 7 lines below, 2 tileS to the right 98 | add hl, de 99 | ex de, hl 100 | 101 | push de 102 | ld hl, Settings_Data.CHECKBOX_SHOW_TICKS ; RAM address (source) 103 | ld b, 12 ; size of line 104 | ld c, 1 ; number of lines 105 | call DRAW_ON_WINDOW_USEFUL_AREA 106 | 107 | 108 | ; if (CHECKBOX_SHOW_TICKS_VALUE != 0) 109 | ld a, (iy + SETTINGS_VARS.CHECKBOX_SHOW_TICKS_VALUE) 110 | or a 111 | pop hl 112 | ret z 113 | 114 | call BIOS_SETWRT 115 | ld a, TILE_CHECKBOX_CHECKED 116 | out (PORT_0), a 117 | 118 | 119 | 120 | ret 121 | 122 | 123 | 124 | ; draw system time on window 125 | .DrawClock: 126 | 127 | call GET_USEFUL_WINDOW_BASE_NAMTBL 128 | ld de, 2 + (32 * 5) 129 | add hl, de 130 | call BIOS_SETWRT 131 | ld c, PORT_0 132 | 133 | 134 | ld b, TILE_FONT_NUMBERS_0 135 | 136 | ; tens of hours digit 137 | ld a, (OS.currentTime_Hours) 138 | srl a ; shift right n, bit 7 = 0, carry = 0 139 | srl a ; shift right n, bit 7 = 0, carry = 0 140 | srl a ; shift right n, bit 7 = 0, carry = 0 141 | srl a ; shift right n, bit 7 = 0, carry = 0 142 | or a 143 | jp z, .skipTensOfHours ; if tens of hours == 0 not print 144 | add b ; convert digit in BCD to tile number 145 | jp .continue 146 | .skipTensOfHours: 147 | ld a, TILE_EMPTY 148 | .continue: 149 | out (c), a 150 | 151 | ; units of hours digit 152 | ld a, (OS.currentTime_Hours) 153 | and 0000 1111 b 154 | add b ; convert digit in BCD to tile number 155 | out (c), a 156 | 157 | ; write char ':' 158 | nop 159 | nop 160 | ld a, TILE_COLON ; char ':' 161 | out (c), a 162 | 163 | ; tens of minutes digit 164 | ld a, (OS.currentTime_Minutes) 165 | srl a ; shift right n, bit 7 = 0, carry = 0 166 | srl a ; shift right n, bit 7 = 0, carry = 0 167 | srl a ; shift right n, bit 7 = 0, carry = 0 168 | srl a ; shift right n, bit 7 = 0, carry = 0 169 | add b ; convert digit in BCD to tile number 170 | out (c), a 171 | 172 | ; units of minutes digit 173 | ld a, (OS.currentTime_Minutes) 174 | and 0000 1111 b 175 | add b ; convert digit in BCD to tile number 176 | out (c), a 177 | 178 | ; write char ':' 179 | nop 180 | nop 181 | ld a, TILE_COLON ; char ':' 182 | out (c), a 183 | 184 | ; tens of seconds digit 185 | ld a, (OS.currentTime_Seconds) 186 | srl a ; shift right n, bit 7 = 0, carry = 0 187 | srl a ; shift right n, bit 7 = 0, carry = 0 188 | srl a ; shift right n, bit 7 = 0, carry = 0 189 | srl a ; shift right n, bit 7 = 0, carry = 0 190 | add b ; convert digit in BCD to tile number 191 | out (c), a 192 | 193 | ; units of seconds digit 194 | ld a, (OS.currentTime_Seconds) 195 | and 0000 1111 b 196 | add b ; convert digit in BCD to tile number 197 | out (c), a 198 | 199 | 200 | ; if (checkboxShowTicks == false) ret 201 | ld a, (iy + SETTINGS_VARS.CHECKBOX_SHOW_TICKS_VALUE) 202 | or a 203 | ret z 204 | 205 | ; ---- write system time ticks counter (in hex) 206 | 207 | ; write char '.' 208 | ld a, TILE_DOT ; char '.' 209 | out (c), a 210 | 211 | 212 | ld a, (OS.timeCounter) 213 | ld d, a ; save A reg 214 | and 1111 0000 b 215 | srl a ; shift right n, bit 7 = 0, carry = 0 216 | srl a ; shift right n, bit 7 = 0, carry = 0 217 | srl a ; shift right n, bit 7 = 0, carry = 0 218 | srl a ; shift right n, bit 7 = 0, carry = 0 219 | ld b, TILE_FONT_NUMBERS_0 + 0 220 | add b 221 | out (PORT_0), a 222 | 223 | ld a, d ; restore a 224 | and 0000 1111 b 225 | ld b, TILE_FONT_NUMBERS_0 + 0 226 | add b 227 | out (PORT_0), a 228 | 229 | 230 | 231 | 232 | 233 | ret 234 | --------------------------------------------------------------------------------