mirror of
https://github.com/vivier/EMILE.git
synced 2025-03-08 20:30:50 +00:00
remove apple_driver
This commit is contained in:
parent
833dfa6cf1
commit
e05ef43e51
21
Makefile
21
Makefile
@ -17,14 +17,14 @@ include kernel.mk
|
||||
clean libemile-clean libmacos-clean libunix-clean tools-clean \
|
||||
first-clean second-clean docs-clean libiso9660-clean libgzip-clean \
|
||||
libfloppy-clean libscsi-clean libstream-clean libblock-clean dist docs \
|
||||
apple_driver apple_driver_clean libconfig libconfig-m68k libmap \
|
||||
libconfig libconfig-m68k libmap \
|
||||
libmap-m68k libext2 libext2-m68k
|
||||
|
||||
all: tools.mk docs libemile libblock libiso9660 libiso9660-m68k libgzip-m68k \
|
||||
tools first libstream libcontainer libmap libext2 libext2-m68k \
|
||||
second/$(KARCH)-linux-floppy/second \
|
||||
second/$(KARCH)-linux-scsi/second second/m68k-netbsd-floppy/second \
|
||||
apple_driver libconfig libconfig-m68k \
|
||||
libconfig libconfig-m68k \
|
||||
second/$(KARCH)-linux-all/second
|
||||
|
||||
tools.mk: scripts/tools.sh
|
||||
@ -173,9 +173,6 @@ export SIGNATURE VERSION DESTDIR PREFIX KARCH CROSS_COMPILE
|
||||
first::
|
||||
$(MAKE) -C first TARGET=m68k-linux
|
||||
|
||||
apple_driver::
|
||||
$(MAKE) -C apple_driver TARGET=m68k-linux
|
||||
|
||||
second/$(KARCH)-linux-floppy/second:: libmacos libunix libiso9660-m68k libext2-m68k libgzip-m68k libfloppy libscsi libstream libblock libcontainer libui libconfig-m68k libmap-m68k
|
||||
$(MAKE) -C second MEDIA=floppy TARGET=$(KARCH)-linux
|
||||
|
||||
@ -272,19 +269,13 @@ docs-install:: docs
|
||||
docs-uninstall::
|
||||
$(MAKE) -C docs uninstall
|
||||
|
||||
apple_driver-install::
|
||||
$(MAKE) -C apple_driver install
|
||||
|
||||
apple_driver-uninstall::
|
||||
$(MAKE) -C apple_driver uninstall
|
||||
|
||||
docs::
|
||||
$(MAKE) -C docs all
|
||||
|
||||
dump: last.bin
|
||||
dd if=last.bin of=$(FLOPPY) bs=512
|
||||
|
||||
install: tools-install first-install second-install docs-install apple_driver-install
|
||||
install: tools-install first-install second-install docs-install
|
||||
|
||||
uninstall: tools-uninstall first-uninstall second-uninstall docs-uninstall
|
||||
|
||||
@ -347,9 +338,6 @@ docs-clean:
|
||||
libfloppy-clean:
|
||||
$(MAKE) -C libfloppy clean
|
||||
|
||||
apple_driver-clean:
|
||||
$(MAKE) -C apple_driver clean
|
||||
|
||||
distclean:: clean
|
||||
rm -f tools.mk
|
||||
|
||||
@ -357,7 +345,7 @@ clean:: libemile-clean libmacos-clean libunix-clean tools-clean first-clean \
|
||||
second-clean docs-clean libiso9660-clean libext2-clean libgzip-clean \
|
||||
libfloppy-clean \
|
||||
libscsi-clean libstream-clean libblock-clean libcontainer-clean \
|
||||
apple_driver-clean libui-clean libconfig-clean libmap-clean
|
||||
libui-clean libconfig-clean libmap-clean
|
||||
rm -f floppy.bin floppy.bin.X floppy_ramdisk.bin \
|
||||
floppy_ramdisk.bin.X rescue.bin rescue.bin.X \
|
||||
debian-installer.bin debian-installer.bin.X \
|
||||
@ -390,7 +378,6 @@ dist:
|
||||
@$(MAKE) -C libgzip dist DISTDIR=$(shell pwd)/$(PACKAGE)-$(VERSION)
|
||||
@$(MAKE) -C tools dist DISTDIR=$(shell pwd)/$(PACKAGE)-$(VERSION)
|
||||
@$(MAKE) -C debian dist DISTDIR=$(shell pwd)/$(PACKAGE)-$(VERSION)
|
||||
@$(MAKE) -C apple_driver dist DISTDIR=$(shell pwd)/$(PACKAGE)-$(VERSION)
|
||||
@$(MAKE) -C libconfig dist DISTDIR=$(shell pwd)/$(PACKAGE)-$(VERSION)
|
||||
@$(MAKE) -C libmap dist DISTDIR=$(shell pwd)/$(PACKAGE)-$(VERSION)
|
||||
@echo TAR emile
|
||||
|
@ -1,53 +0,0 @@
|
||||
#
|
||||
#
|
||||
# (c) 2004-2007 Laurent Vivier <Laurent@lvivier.info>
|
||||
#
|
||||
#
|
||||
|
||||
TOP = $(shell pwd)
|
||||
VPATH = $(TOP)
|
||||
|
||||
CPPFLAGS = -DARCH_M68K -I$(TOP)/../libmacos -Wa,-I$(TOP)/../libmacos
|
||||
|
||||
ASFLAGS = -I$(TOP)
|
||||
|
||||
CFLAGS += $(OPT_CFLAGS) -nostdlib -nodefaultlibs -Wall -Werror -Wno-multichar -fpic -O2
|
||||
LIBS = -L$(TOP)/../libunix -lunix -L$(TOP)/../libmacos -lmacos
|
||||
|
||||
SOURCES = head.S main.c console.c vga.c font_8x16.c
|
||||
|
||||
HEADERS = vga.h console.h misc.h
|
||||
|
||||
PROGRAMS = apple_driver
|
||||
|
||||
CLEAN = apple_driver.o
|
||||
|
||||
.PHONY: all
|
||||
|
||||
all: apple_driver
|
||||
|
||||
include $(TOP)/../tools.mk
|
||||
include $(TOP)/../Rules.mk
|
||||
|
||||
DISTFILES += ld.script
|
||||
|
||||
apple_driver: apple_driver.o
|
||||
$(OBJCOPY) -j .text -j .data -j .rodata -j .got \
|
||||
-O binary apple_driver.o apple_driver
|
||||
|
||||
apple_driver.o: $(OBJS) ld.script
|
||||
$(LD) -T ld.script -o apple_driver.o $(OBJS) $(LIBS)
|
||||
|
||||
.S.o:
|
||||
$(AS) $(ASFLAGS) -o $@ $^
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $^
|
||||
|
||||
install::
|
||||
install -d $(DESTDIR)/$(PREFIX)/lib/emile/
|
||||
install apple_driver $(DESTDIR)/$(PREFIX)/lib/emile/apple_driver
|
||||
|
||||
uninstall::
|
||||
rm -f $(DESTDIR)/$(PREFIX)/lib/emile/apple_driver
|
||||
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004 Laurent Vivier <Laurent@lvivier.info>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <macos/lowmem.h>
|
||||
|
||||
#include "console.h"
|
||||
#include "vga.h"
|
||||
|
||||
void
|
||||
console_init()
|
||||
{
|
||||
vga_init();
|
||||
}
|
||||
|
||||
int console_putchar(int c)
|
||||
{
|
||||
vga_put(c);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void console_putstring(const char *s)
|
||||
{
|
||||
while(*s)
|
||||
console_putchar(*(s++));
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004 Laurent Vivier <Laurent@lvivier.info>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __CONSOLE_H__
|
||||
#define __CONSOLE_H__
|
||||
|
||||
#include <macos/types.h>
|
||||
|
||||
extern void console_init(void);
|
||||
extern inline int console_putchar(int c);
|
||||
extern void console_putstring(const char *s);
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,117 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2006 Laurent Vivier <Laurent@lvivier.info>
|
||||
*
|
||||
* based on http://developer.apple.com/technotes/tn/tn1189.html
|
||||
*
|
||||
*/
|
||||
|
||||
.cpu 68000
|
||||
|
||||
.macro SysError
|
||||
.short 0xA9C9
|
||||
.endm
|
||||
|
||||
.macro NewPtrClear
|
||||
.short 0xA31E
|
||||
.endm
|
||||
|
||||
.align 4
|
||||
_start:
|
||||
primary_entry_point:
|
||||
bra.w primary_setup
|
||||
dc.l 0x0001
|
||||
|
||||
secondary_entry_point:
|
||||
bra.w secondary_setup
|
||||
|
||||
_driver_name:
|
||||
.string ".EMILE"
|
||||
_version:
|
||||
dc.w 0x001
|
||||
_id:
|
||||
.string "EMILE SCSI 0.0.1"
|
||||
|
||||
.string "APPLE_DRIVER for EMILE"
|
||||
.string "(c) 2006 Laurent Vivier <Laurent@lvivier.info>"
|
||||
.string "All files are distributed under the terms of GPLv2 license."
|
||||
|
||||
.align 4
|
||||
primary_setup:
|
||||
ori.l #0x0f000000, %d5
|
||||
|
||||
secondary_setup:
|
||||
|
||||
movem.l %d1-%a4,%sp@-
|
||||
move.l %d5, %sp@-
|
||||
bsr driver_entry
|
||||
add.l #4, %sp
|
||||
movem.l %sp@+, %d1-%a4
|
||||
rts
|
||||
|
||||
driver_entry:
|
||||
bsr relocate
|
||||
|
||||
bsr console_init@PLTPC
|
||||
move.l %d5, -(%sp)
|
||||
bsr start@PLTPC
|
||||
|
||||
rts
|
||||
|
||||
relocate:
|
||||
/* Allocate BSS section */
|
||||
|
||||
move.l #__bss_size, %d0 /* size */
|
||||
/* Alloc and clear memory (needed by GCC 3) */
|
||||
NewPtrClear /* result in %a0 */
|
||||
move.l %a0, %d0
|
||||
bne malloc_ok
|
||||
SysError
|
||||
malloc_ok:
|
||||
move.l %a0,%d3
|
||||
move.l #__bss_start, %d0
|
||||
sub.l %d0,%d3 /* %d3 is the offset to add for BSS */
|
||||
|
||||
/* real address of GOT */
|
||||
|
||||
lea _GLOBAL_OFFSET_TABLE_-.-8,%a0
|
||||
lea (%pc, %a0), %a0
|
||||
|
||||
/* linked address of GOT */
|
||||
|
||||
move.l #_GLOBAL_OFFSET_TABLE_, %d0
|
||||
|
||||
/* %d2 is the offset to add for all other sections */
|
||||
|
||||
move.l %a0,%d2
|
||||
sub.l %d0,%d2
|
||||
|
||||
/* relocate BSS section */
|
||||
|
||||
move.l #__got_size, %d0
|
||||
beq exit_relocate
|
||||
|
||||
got_loop:
|
||||
move.l (%a0), %d1
|
||||
|
||||
cmp.l #__bss_start.l, %d1
|
||||
blt other_section
|
||||
cmp.l #_end.l, %d1
|
||||
bgt other_section
|
||||
|
||||
/* symbol in section BSS */
|
||||
|
||||
add.l %d3, %d1
|
||||
bra got_store
|
||||
|
||||
other_section:
|
||||
add.l %d2, %d1
|
||||
|
||||
got_store:
|
||||
move.l %d1, (%a0)+
|
||||
|
||||
subq.l #4, %d0
|
||||
bgt got_loop
|
||||
|
||||
exit_relocate:
|
||||
rts
|
@ -1,92 +0,0 @@
|
||||
OUTPUT_ARCH(m68k)
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
__bootloader_start = .;
|
||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
||||
*(.gnu.warning)
|
||||
} =0x4e754e75
|
||||
.hash : { *(.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.rel.dyn :
|
||||
{
|
||||
*(.rel.init)
|
||||
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
|
||||
*(.rel.fini)
|
||||
*(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
|
||||
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
|
||||
*(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
|
||||
*(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
|
||||
*(.rel.ctors)
|
||||
*(.rel.dtors)
|
||||
*(.rel.got)
|
||||
*(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
|
||||
}
|
||||
.rela.dyn :
|
||||
{
|
||||
*(.rela.init)
|
||||
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
|
||||
*(.rela.fini)
|
||||
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
|
||||
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
|
||||
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
|
||||
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
|
||||
*(.rela.ctors)
|
||||
*(.rela.dtors)
|
||||
*(.rela.got)
|
||||
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
|
||||
}
|
||||
.rel.plt : { *(.rel.plt) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
.init :
|
||||
{
|
||||
KEEP (*(.init))
|
||||
} =0x4e754e75
|
||||
.plt : { *(.plt) }
|
||||
.fini :
|
||||
{
|
||||
KEEP (*(.fini))
|
||||
} =0x4e754e75
|
||||
PROVIDE (__etext = .);
|
||||
PROVIDE (_etext = .);
|
||||
PROVIDE (etext = .);
|
||||
.rodata : {
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
}
|
||||
.rodata1 : { *(.rodata1) }
|
||||
.eh_frame_hdr : { *(.eh_frame_hdr) }
|
||||
. = ALIGN(0x2000) + (. & (0x2000 - 1));
|
||||
. = ALIGN(32 / 8);
|
||||
.preinit_array : { *(.preinit_array) }
|
||||
.init_array : { *(.init_array) }
|
||||
.fini_array : { *(.fini_array) }
|
||||
.data :
|
||||
{
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
SORT(CONSTRUCTORS)
|
||||
}
|
||||
.data1 : { *(.data1) }
|
||||
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
|
||||
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
|
||||
.eh_frame : { KEEP (*(.eh_frame)) }
|
||||
.gcc_except_table : { *(.gcc_except_table) }
|
||||
.dynamic : { *(.dynamic) }
|
||||
.got : { *(.got.plt) *(.got) }
|
||||
__got_size = . - _GLOBAL_OFFSET_TABLE_;
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
__bss_start = .;
|
||||
.bss :
|
||||
{
|
||||
*(.dynbss)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(32 / 8);
|
||||
}
|
||||
. = ALIGN(32 / 8);
|
||||
__bss_size = . - __bss_start;
|
||||
_end = .;
|
||||
PROVIDE (end = .);
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
#define __NO_INLINE__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int start(int origin)
|
||||
{
|
||||
printf("Welcome !\n");
|
||||
printf("Origin: %x\n", origin);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004, 2005 Laurent Vivier <Laurent@lvivier.info>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MISC_H__
|
||||
#define __MISC_H__
|
||||
|
||||
extern unsigned char *c2pstring(char* s);
|
||||
extern char *p2cstring(unsigned char* s);
|
||||
extern void memdump(unsigned char* addr, unsigned long size);
|
||||
extern void error(char *x) __attribute__ ((noreturn));
|
||||
|
||||
#endif /* __MISC_H__ */
|
@ -1,534 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004 Laurent Vivier <Laurent@lvivier.info>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <macos/lowmem.h>
|
||||
#include <macos/quickdraw.h>
|
||||
#include <libmacos.h>
|
||||
|
||||
#include "misc.h"
|
||||
#include "vga.h"
|
||||
|
||||
QDGlobals qd;
|
||||
|
||||
typedef struct vga_handler {
|
||||
|
||||
unsigned char* video;
|
||||
unsigned char* base;
|
||||
unsigned long row_bytes; /* in bytes */
|
||||
unsigned long depth; /* 4, 8, 16 or 32 */
|
||||
unsigned long width; /* in pixels */
|
||||
unsigned long height;
|
||||
|
||||
unsigned long siz_w, siz_h;
|
||||
unsigned long pos_x, pos_y;
|
||||
|
||||
} vga_handler_t ;
|
||||
|
||||
static unsigned char bits_depth2[16] = {
|
||||
0x00, /* 0 : 0000 -> 00000000 */
|
||||
0x03, /* 1 : 0001 -> 00000011 */
|
||||
0x0c, /* 2 : 0010 -> 00001100 */
|
||||
0x0f, /* 3 : 0011 -> 00001111 */
|
||||
0x30, /* 4 : 0100 -> 00110000 */
|
||||
0x33, /* 5 : 0101 -> 00110011 */
|
||||
0x3c, /* 6 : 0110 -> 00111100 */
|
||||
0x3f, /* 7 : 0111 -> 00111111 */
|
||||
0xc0, /* 8 : 1000 -> 11000000 */
|
||||
0xc3, /* 9 : 1001 -> 11000011 */
|
||||
0xcc, /* 10 : 1010 -> 11001100 */
|
||||
0xcf, /* 11 : 1011 -> 11001111 */
|
||||
0xf0, /* 12 : 1100 -> 11110000 */
|
||||
0xf3, /* 13 : 1101 -> 11110011 */
|
||||
0xfc, /* 14 : 1110 -> 11111100 */
|
||||
0xff /* 15 : 1111 -> 11111111 */
|
||||
};
|
||||
|
||||
static unsigned char bits_depth4[4] = {
|
||||
0x00, /* 0 : 00 -> 00000000 */
|
||||
0x0f, /* 1 : 01 -> 00001111 */
|
||||
0xf0, /* 2 : 10 -> 11110000 */
|
||||
0xFF /* 3 : 11 -> 11111111 */
|
||||
};
|
||||
|
||||
static unsigned char bits_depth8[2] = {
|
||||
0x00, /* 0 : 0 -> 00000000 */
|
||||
0xff /* 0 : 1 -> 11111111 */
|
||||
};
|
||||
|
||||
static vga_handler_t vga =
|
||||
{
|
||||
.video = 0,
|
||||
.base = 0,
|
||||
.row_bytes = 0,
|
||||
.depth = 0,
|
||||
.width = 0,
|
||||
.height = 0,
|
||||
.siz_w = 0,
|
||||
.siz_h = 0,
|
||||
.pos_x = 0,
|
||||
.pos_y = 0
|
||||
};
|
||||
|
||||
static unsigned long cursor_save_x, cursor_save_y;
|
||||
|
||||
#define CURSOR_POS 0
|
||||
#define CURSOR_HIGH 16
|
||||
|
||||
static int cursor_on = 0;
|
||||
static int cursor_state = 0;
|
||||
|
||||
extern unsigned char* font_get(int c);
|
||||
|
||||
static void
|
||||
draw_cursor(void)
|
||||
{
|
||||
int l,w;
|
||||
unsigned char *base;
|
||||
unsigned long x_base;
|
||||
unsigned long y_base;
|
||||
|
||||
y_base = vga.row_bytes * vga.pos_y * 16;
|
||||
x_base = vga.pos_x * vga.depth;
|
||||
|
||||
base = vga.base + y_base + x_base;
|
||||
|
||||
base += CURSOR_POS * vga.row_bytes;
|
||||
for (l = 0 ; l < CURSOR_HIGH ; l++)
|
||||
{
|
||||
for (w = 0; w < vga.depth; w++)
|
||||
base[w] ^= 0xFF;
|
||||
base += vga.row_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
static void vga_cursor(int state)
|
||||
{
|
||||
if (cursor_state != state)
|
||||
{
|
||||
draw_cursor();
|
||||
cursor_state = state;
|
||||
}
|
||||
}
|
||||
|
||||
void vga_cursor_refresh(void)
|
||||
{
|
||||
if (!cursor_on)
|
||||
return;
|
||||
|
||||
if (Ticks % 60 < 30)
|
||||
vga_cursor(0);
|
||||
else
|
||||
vga_cursor(1);
|
||||
}
|
||||
|
||||
void vga_cursor_on(void)
|
||||
{
|
||||
cursor_on = 1;
|
||||
vga_cursor_refresh();
|
||||
}
|
||||
|
||||
void vga_cursor_off(void)
|
||||
{
|
||||
cursor_on = 0;
|
||||
vga_cursor(0);
|
||||
}
|
||||
|
||||
void vga_cursor_save(void)
|
||||
{
|
||||
cursor_save_x = vga.pos_x;
|
||||
cursor_save_y = vga.pos_y;
|
||||
}
|
||||
|
||||
void vga_cursor_restore(void)
|
||||
{
|
||||
vga_cursor(0);
|
||||
vga.pos_x = cursor_save_x;
|
||||
vga.pos_y = cursor_save_y;
|
||||
vga_cursor(1);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_byte_1(unsigned char *glyph, unsigned char *base)
|
||||
{
|
||||
int l;
|
||||
|
||||
for (l = 0 ; l < 16; l++)
|
||||
{
|
||||
*base = ~(*glyph++);
|
||||
base += vga.row_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_byte_2(unsigned char *glyph, unsigned char *base)
|
||||
{
|
||||
int l;
|
||||
int bits;
|
||||
|
||||
for (l = 0 ; l < 16; l++)
|
||||
{
|
||||
bits = ~(*glyph++);
|
||||
|
||||
base[1] = bits_depth2[bits & 0x0F];
|
||||
bits = bits >> 4;
|
||||
base[0] = bits_depth2[bits & 0x0F];
|
||||
|
||||
base += vga.row_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_byte_4(unsigned char *glyph, unsigned char *base)
|
||||
{
|
||||
int l;
|
||||
int bits;
|
||||
|
||||
for (l = 0 ; l < 16; l++)
|
||||
{
|
||||
bits = ~(*glyph++);
|
||||
|
||||
base[3] = bits_depth4[bits & 0x03];
|
||||
bits = bits >> 2;
|
||||
|
||||
base[2] = bits_depth4[bits & 0x03];
|
||||
bits = bits >> 2;
|
||||
|
||||
base[1] = bits_depth4[bits & 0x03];
|
||||
bits = bits >> 2;
|
||||
|
||||
base[0] = bits_depth4[bits & 0x03];
|
||||
|
||||
base += vga.row_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_byte_8(unsigned char *glyph, unsigned char *base)
|
||||
{
|
||||
int l;
|
||||
int bits;
|
||||
|
||||
for (l = 0 ; l < 16; l++)
|
||||
{
|
||||
bits = ~(*glyph++);
|
||||
|
||||
base[7] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
base[6] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
base[5] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
base[4] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
base[3] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
base[2] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
base[1] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
base[0] = bits_depth8[bits & 0x01];
|
||||
|
||||
base += vga.row_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_byte_16(unsigned char *glyph, unsigned char *base)
|
||||
{
|
||||
int l;
|
||||
int bits;
|
||||
|
||||
for (l = 0 ; l < 16; l++)
|
||||
{
|
||||
bits = *glyph++;
|
||||
|
||||
base[15] = base[14] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[13] = base[12] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[11] = base[10] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[9] = base[8] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[7] = base[6] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[5] = base[4] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[3] = base[2] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[1] = base[0] = bits_depth8[bits & 0x01];
|
||||
|
||||
base += vga.row_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_byte_24(unsigned char *glyph, unsigned char *base)
|
||||
{
|
||||
int l;
|
||||
int bits;
|
||||
|
||||
for (l = 0 ; l < 16; l++)
|
||||
{
|
||||
bits = *glyph++;
|
||||
|
||||
base[23] = base[22] = base[21] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[20] = base[19] = base[18] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[17] = base[16] = base[15] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[14] = base[13] = base[12] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[11] = base[10] = base[9] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[8] = base[7] = base[6] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[5] = base[4] = base[3] = bits_depth8[bits & 0x01];
|
||||
bits = bits >> 1;
|
||||
|
||||
base[2] = base[1] = base[0] = bits_depth8[bits & 0x01];
|
||||
|
||||
base += vga.row_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_byte(unsigned char c, unsigned long locX, unsigned long locY)
|
||||
{
|
||||
unsigned char *base;
|
||||
unsigned char *glyph;
|
||||
unsigned long x_base;
|
||||
unsigned long y_base;
|
||||
|
||||
glyph = font_get(c);
|
||||
|
||||
y_base = vga.row_bytes * locY * 16;
|
||||
x_base = locX * vga.depth;
|
||||
|
||||
base = vga.base + y_base + x_base;
|
||||
|
||||
switch(vga.depth)
|
||||
{
|
||||
case 1:
|
||||
draw_byte_1(glyph, base);
|
||||
break;
|
||||
case 2:
|
||||
draw_byte_2(glyph, base);
|
||||
break;
|
||||
case 4:
|
||||
draw_byte_4(glyph, base);
|
||||
break;
|
||||
case 8:
|
||||
draw_byte_8(glyph, base);
|
||||
break;
|
||||
case 16:
|
||||
draw_byte_16(glyph, base);
|
||||
break;
|
||||
case 24:
|
||||
draw_byte_24(glyph, base);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void vga_clear();
|
||||
|
||||
static void
|
||||
vga_scroll()
|
||||
{
|
||||
unsigned long j;
|
||||
unsigned long i;
|
||||
unsigned long *src;
|
||||
unsigned long *dst;
|
||||
unsigned long bg32;
|
||||
|
||||
/* move up the screen */
|
||||
|
||||
src = (unsigned long *)(vga.base + (vga.row_bytes << 4));
|
||||
dst = (unsigned long *)vga.base;
|
||||
|
||||
for (j = 0; j < vga.siz_h - 1; j++)
|
||||
for (i = 0; i < (vga.row_bytes<<2); i++)
|
||||
*dst++ = *src++;
|
||||
|
||||
/* clear last line */
|
||||
|
||||
if (vga.depth <= 8)
|
||||
bg32 = 0xffffffff;
|
||||
else
|
||||
bg32 = 0x00000000;
|
||||
|
||||
for (j = 0; j < (vga.row_bytes << 2); j++)
|
||||
*dst++ = bg32;
|
||||
}
|
||||
|
||||
int
|
||||
vga_init()
|
||||
{
|
||||
GDHandle hdl;
|
||||
volatile PixMapPtr pm;
|
||||
|
||||
InitGraf(&qd.thePort);
|
||||
|
||||
hdl = LMGetMainDevice();
|
||||
|
||||
if ( (hdl == (GDHandle)0xAAAAAAAA) || (hdl == NULL) ||
|
||||
((**hdl).gdPMap == NULL) || ((*(**hdl).gdPMap)->baseAddr == NULL) )
|
||||
{
|
||||
vga.base = qd.screenBits.baseAddr;
|
||||
vga.row_bytes = qd.screenBits.rowBytes;
|
||||
vga.width = qd.screenBits.bounds.right -
|
||||
qd.screenBits.bounds.left;
|
||||
vga.height = qd.screenBits.bounds.bottom -
|
||||
qd.screenBits.bounds.top;
|
||||
vga.depth = 1;
|
||||
} else {
|
||||
pm = *(**hdl).gdPMap;
|
||||
|
||||
vga.video = (unsigned char *)pm->baseAddr;
|
||||
vga.row_bytes = pm->rowBytes & 0x3fff;
|
||||
vga.width = pm->bounds.right - pm->bounds.left;
|
||||
vga.height = pm->bounds.bottom - pm->bounds.top;
|
||||
vga.depth = pm->pixelSize;
|
||||
if (vga.depth == 15)
|
||||
vga.depth = 16;
|
||||
}
|
||||
|
||||
vga.base = vga.video + pm->bounds.top * vga.row_bytes + pm->bounds.left * (vga.depth >> 3);
|
||||
|
||||
vga.pos_x = 0;
|
||||
vga.pos_y = 0;
|
||||
vga.siz_w = vga.width / 8;
|
||||
vga.siz_h = vga.height / 16;
|
||||
|
||||
vga_clear();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
vga_put(char c)
|
||||
{
|
||||
vga_cursor(0);
|
||||
|
||||
switch(c) {
|
||||
case '\r':
|
||||
vga.pos_x = 0;
|
||||
break;
|
||||
case '\n':
|
||||
vga.pos_x = 0;
|
||||
vga.pos_y++;
|
||||
break;
|
||||
case '\b':
|
||||
if (vga.pos_x > 0)
|
||||
vga.pos_x--;
|
||||
else if (vga.pos_y > 0)
|
||||
{
|
||||
vga.pos_y--;
|
||||
vga.pos_x = vga.siz_w - 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
draw_byte((unsigned char)c, vga.pos_x++, vga.pos_y);
|
||||
if (vga.pos_x >= vga.siz_w) {
|
||||
vga.pos_x = 0;
|
||||
vga.pos_y++;
|
||||
}
|
||||
}
|
||||
while (vga.pos_y >= vga.siz_h) {
|
||||
vga_scroll();
|
||||
vga.pos_y--;
|
||||
}
|
||||
|
||||
vga_cursor_refresh();
|
||||
}
|
||||
|
||||
static void
|
||||
vga_clear()
|
||||
{
|
||||
int i,j;
|
||||
unsigned long row;
|
||||
unsigned char bg;
|
||||
unsigned long bg32;
|
||||
unsigned long *base;
|
||||
unsigned char *next;
|
||||
|
||||
vga_cursor(0);
|
||||
|
||||
if (vga.depth <= 8)
|
||||
{
|
||||
bg = 0xff;
|
||||
bg32 = 0xffffffff;
|
||||
}
|
||||
else
|
||||
{
|
||||
bg = 0x00;
|
||||
bg32 = 0x00000000;
|
||||
}
|
||||
|
||||
for (j = 0, row = 0; j < vga.height; j++)
|
||||
{
|
||||
base = (unsigned long*)(vga.base + row);
|
||||
row += vga.row_bytes;
|
||||
|
||||
for (i = 0; i < (vga.row_bytes >> 2); i++)
|
||||
*base++ = bg32;
|
||||
next = (unsigned char*)base;
|
||||
for (i = i << 2 ; i < vga.row_bytes; i++)
|
||||
*next++ = bg;
|
||||
}
|
||||
|
||||
vga.pos_x = 0;
|
||||
vga.pos_y = 0;
|
||||
|
||||
vga_cursor_refresh();
|
||||
}
|
||||
|
||||
unsigned long vga_get_videobase()
|
||||
{
|
||||
return (unsigned long)vga.base;
|
||||
}
|
||||
|
||||
unsigned long vga_get_row_bytes()
|
||||
{
|
||||
return vga.row_bytes;
|
||||
}
|
||||
|
||||
unsigned long vga_get_depth()
|
||||
{
|
||||
return vga.depth;
|
||||
}
|
||||
|
||||
unsigned long vga_get_width()
|
||||
{
|
||||
return vga.width;
|
||||
}
|
||||
|
||||
unsigned long vga_get_height()
|
||||
{
|
||||
return vga.height;
|
||||
}
|
||||
|
||||
unsigned long vga_get_video()
|
||||
{
|
||||
return (unsigned long)vga.video;
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2004 Laurent Vivier <Laurent@lvivier.info>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __VGA_H__
|
||||
#define __VGA_H__
|
||||
|
||||
extern int vga_init();
|
||||
|
||||
extern void vga_put(char c);
|
||||
extern void vga_print(char *s);
|
||||
extern void vga_cursor_refresh(void);
|
||||
extern void vga_cursor_on(void);
|
||||
extern void vga_cursor_off(void);
|
||||
extern void vga_cursor_save(void);
|
||||
extern void vga_cursor_restore(void);
|
||||
|
||||
extern unsigned long vga_get_videobase();
|
||||
extern unsigned long vga_get_row_bytes();
|
||||
extern unsigned long vga_get_depth();
|
||||
extern unsigned long vga_get_width();
|
||||
extern unsigned long vga_get_height();
|
||||
extern unsigned long vga_get_video();
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user