KEMBAR78
Sistema Operacioal em ASM para o Sega Master System | PDF | Text File | Office Equipment
0% found this document useful (0 votes)
29 views4 pages

Sistema Operacioal em ASM para o Sega Master System

Uploaded by

gelasioescola
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views4 pages

Sistema Operacioal em ASM para o Sega Master System

Uploaded by

gelasioescola
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

; main.asm.

txt - Main Bootstrapping for the Sega Master System OS inspired by


Windows 95

; Include system files provided in the project


INCLUDE 'windows95-sms-kernel.txt'
INCLUDE 'windows95-sms-file-manager.txt'
INCLUDE 'windows95-sms-paint.txt'
INCLUDE 'windows95-sms-text-editor.txt'
INCLUDE 'windows95-sms-clock.txt'
INCLUDE 'windows95-sms-disk-usage.txt'
INCLUDE 'windows95-sms-memory-usage.txt'
INCLUDE 'windows95-sms-userland.txt'
INCLUDE 'windows95-sms-calculator.txt'

; --------------------------------------------------
; MAIN BOOTLOADER
; --------------------------------------------------

.org $0000

di ; Disable interrupts during setup


im 1 ; Set interrupt mode 1
jp init ; Jump to initialization

; Interrupt handler
.org $0038
call handleInterrupt
reti

init:
call initHardware ; Initialize hardware (VDP, sound, etc.)
call initMemory ; Initialize memory and clear it
call loadUserland ; Load userland apps and system utilities
jp mainLoop

mainLoop:
; Main loop of the operating system
call checkAppSwitch ; Check if the user wants to switch apps
call runCurrentApp ; Run the currently selected app
jp mainLoop ; Repeat

; --------------------------------------------------
; INTERRUPT HANDLER
; --------------------------------------------------

handleInterrupt:
; Handle system interrupts here (e.g., input handling, system timers)
reti

; --------------------------------------------------
; HARDWARE INITIALIZATION
; --------------------------------------------------

initHardware:
call VDP_Setup ; Initialize Video Display Processor
call PSG_Init ; Initialize sound system (AY-3-8910 emulator)
call Palette_Init ; Initialize color palette for the display
ret
; --------------------------------------------------
; SYSTEM MEMORY INITIALIZATION
; --------------------------------------------------

initMemory:
ld hl, $8000 ; Start of SRAM
ld de, $A000 ; End of SRAM (8KB)
clearMemoryLoop:
ld (hl), 0 ; Clear memory
inc hl
cp hl, de
jp nz, clearMemoryLoop
ret

; --------------------------------------------------
; USERLAND LOADER
; --------------------------------------------------

loadUserland:
; Load user applications (calculator, file manager, text editor, etc.)
include 'windows95-sms-userland.txt'
ret

; --------------------------------------------------
; SYSTEM FUNCTIONS AND APPLICATIONS
; --------------------------------------------------

include 'windows95-sms-kernel.txt'
include 'windows95-sms-file-manager.txt'
include 'windows95-sms-paint.txt'
include 'windows95-sms-text-editor.txt'
include 'windows95-sms-clock.txt'
include 'windows95-sms-disk-usage.txt'
include 'windows95-sms-memory-usage.txt'
include 'windows95-sms-calculator.txt'

; --------------------------------------------------
; VIDEO AND SOUND INITIALIZATION
; --------------------------------------------------

VDP_Setup:
; Initialize VDP with the required screen setup and tilemap configuration
ret

PSG_Init:
; Initialize sound system
ret

Palette_Init:
; Set up palette colors for the display
ret

; --------------------------------------------------
; MAIN APPLICATION LOGIC (Calculator Example)
; --------------------------------------------------

calculatorStart:
call initCalculator
jp calculatorLoop

initCalculator:
call drawCalculatorWindow
call initCalculatorVariables
ret

calculatorLoop:
call handleCalculatorInput
call updateCalculatorDisplay
jp calculatorLoop

handleCalculatorInput:
; Handle joystick input for calculator
call syscall_readJoypad
bit 0,a ; Check Up
jr z,.checkDown
call moveCursorUp
.checkDown:
bit 1,a ; Check Down
jr z,.checkLeft
call moveCursorDown
.checkLeft:
bit 2,a ; Check Left
jr z,.checkRight
call moveCursorLeft
.checkRight:
bit 3,a ; Check Right
jr z,.checkButton1
call moveCursorRight
.checkButton1:
bit 4,a ; Check Button 1 (Select)
ret z
call selectButton
ret

moveCursorUp:
ld a,(cursorY)
cp 5 ; Top row of buttons
ret z
dec a
ld (cursorY),a
ret

moveCursorDown:
ld a,(cursorY)
cp 17 ; Bottom row of buttons
ret z
inc a
ld (cursorY),a
ret

moveCursorLeft:
ld a,(cursorX)
cp 1
ret z
dec a
ld (cursorX),a
ret
moveCursorRight:
ld a,(cursorX)
cp 30 ; Right edge of screen
ret z
inc a
ld (cursorX),a
ret

selectButton:
; Button selection logic
ld a,(cursorY)
sub 5 ; Adjust for button area
ld d,a
ld a,(cursorX)
sub 1
ld e,a
ld hl,calculatorButtons
add hl,de
ld a,(hl)
call processButton
ret

; --------------------------------------------------
; OTHER APPLICATION LOGIC WOULD FOLLOW HERE
; --------------------------------------------------

; Example for text editor, paint, file manager, etc.

You might also like