From f732b2ca13cdbf92f47b1a1dbb9c05bdc1bf22a1 Mon Sep 17 00:00:00 2001 From: NicJA Date: Fri, 3 May 2019 00:55:49 +0000 Subject: [PATCH] revert between 56095 -> 55830 in arch git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@56381 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/all-hosted/libs/hostgl/mmakefile.src | 5 +- arch/all-pc/acpitool/catalogs/french.ct | 90 +- arch/all-pc/acpitool/catalogs/mmakefile.src | 4 +- arch/all-pc/boot/grub-tools/Install-grub.c | 1154 ----------- arch/all-pc/boot/grub-tools/mmakefile.src | 18 - arch/all-pc/boot/grub2-aros/grub-2.02-aros.diff | 58 - arch/all-pc/boot/grub2-host/mmakefile.src | 22 +- arch/all-pc/boot/grub2-tools/Install-grub2.c | 1423 ++++++-------- arch/all-pc/boot/grub2-tools/mmakefile.src | 9 +- arch/all-unix/filesys/emul_handler/emul_host.h | 4 + arch/all-unix/filesys/emul_handler/emul_unix.h | 10 +- arch/all-unix/filesys/emul_handler/mmakefile.src | 4 - arch/arm-raspi/boot/boot.c | 9 +- arch/arm-raspi/boot/elf.c | 16 +- arch/arm-raspi/boot/include/boot.h | 6 - arch/arm-raspi/boot/mmakefile.src | 2 +- arch/i386-pc/boot/floppy/mmakefile.src | 2 +- arch/i386-pc/boot/grub2/grub-efi.cfg | 2 +- arch/i386-pc/boot/grub2/grub.cfg | 2 +- arch/m68k-all/dos/mmakefile.src | 2 +- arch/m68k-all/exec/alert_cpu.c | 6 +- arch/m68k-all/include/gencall.c | 16 +- arch/m68k-all/kernel/kernel_cpu.c | 45 +- arch/m68k-all/kernel/m68k_exception.c | 2 - arch/m68k-all/libgcc1/mmakefile.src | 2 +- arch/m68k-all/mathieeedoubbas/mmakefile.src | 3 +- arch/m68k-all/mathieeedoubtrans/mmakefile.src | 3 +- arch/m68k-all/mathieeesingbas/mmakefile.src | 3 +- arch/m68k-all/mathieeesingtrans/mmakefile.src | 4 +- arch/m68k-amiga/boot/mmakefile.src | 57 +- arch/m68k-amiga/boot/start.c | 31 +- arch/m68k-amiga/c/mmakefile.src | 3 +- arch/m68k-amiga/hidd/amigavideo/amigavideo.conf | 2 +- .../hidd/amigavideo/amigavideo_bitmapclass.c | 743 ++++--- arch/m68k-amiga/hidd/amigavideo/amigavideo_hidd.h | 22 +- .../hidd/amigavideo/amigavideo_hiddclass.c | 1900 +++++++++--------- arch/m68k-amiga/hidd/amigavideo/blitter.c | 3 +- arch/m68k-amiga/hidd/amigavideo/chipset.c | 2032 ++++++++++---------- arch/m68k-amiga/hidd/amigavideo/chipset.h | 2 +- arch/m68k-amiga/hidd/amigavideo/mmakefile.src | 3 +- arch/m68k-amiga/hidd/amigavideo/startup.c | 21 +- arch/m68k-amiga/hidd/gayle_ata/bus_class.h | 3 - arch/m68k-amiga/hidd/gayle_ata/class_init.c | 24 +- arch/m68k-amiga/hidd/gayle_ata/fastata_busclass.c | 9 +- arch/m68k-amiga/hidd/gayle_ata/gayleata_busclass.c | 21 +- arch/m68k-amiga/hidd/gayle_ata/probe.c | 2 +- arch/m68k-amiga/hidd/keyboard/amigakbd.conf | 2 +- arch/m68k-amiga/hidd/keyboard/kbd_init.c | 103 +- arch/m68k-amiga/hidd/keyboard/mmakefile.src | 2 +- .../hidd/keyboard/{kbd_init.c => startup.c} | 4 +- arch/m68k-amiga/hidd/mouse/amigamouse.conf | 2 +- arch/m68k-amiga/hidd/mouse/mmakefile.src | 2 +- arch/m68k-amiga/hidd/mouse/mouse_init.c | 109 +- .../hidd/mouse/{mouse_init.c => startup.c} | 4 +- arch/m68k-amiga/hidd/p96gfx/mmakefile.src | 16 - arch/m68k-amiga/hidd/p96gfx/p96call.c | 133 -- arch/m68k-amiga/hidd/p96gfx/p96gfx_bitmap.h | 38 - arch/m68k-amiga/hidd/p96gfx/p96gfx_bitmapclass.c | 1705 ---------------- arch/m68k-amiga/hidd/p96gfx/p96gfx_card.c | 481 ----- arch/m68k-amiga/hidd/p96gfx/p96gfx_hidd.h | 23 - arch/m68k-amiga/hidd/p96gfx/p96gfx_hiddclass.c | 1657 ---------------- arch/m68k-amiga/hidd/p96gfx/p96gfx_intern.h | 131 -- arch/m68k-amiga/hidd/p96gfx/p96gfx_rtg.c | 138 -- arch/m68k-amiga/hidd/p96gfx/p96gfx_startup.c | 48 - arch/m68k-amiga/hidd/uaegfx/mmakefile.src | 14 + arch/m68k-amiga/hidd/uaegfx/p96call.c | 133 ++ arch/m68k-amiga/hidd/{p96gfx => uaegfx}/p96call.h | 0 arch/m68k-amiga/hidd/uaegfx/startup.c | 58 + .../{p96gfx/p96gfx.conf => uaegfx/uaegfx.conf} | 43 +- arch/m68k-amiga/hidd/uaegfx/uaegfx_bitmap.h | 37 + arch/m68k-amiga/hidd/uaegfx/uaegfx_bitmapclass.c | 1544 +++++++++++++++ arch/m68k-amiga/hidd/uaegfx/uaegfx_hidd.h | 3 + arch/m68k-amiga/hidd/uaegfx/uaegfx_hiddclass.c | 1299 +++++++++++++ arch/m68k-amiga/hidd/uaegfx/uaegfx_intern.h | 123 ++ arch/m68k-amiga/hidd/uaegfx/uaertg.c | 564 ++++++ .../hidd/{p96gfx/p96gfx_rtg.h => uaegfx/uaertg.h} | 177 +- arch/x86_64-pc/boot/grub2/grub-efi.cfg | 2 +- arch/x86_64-pc/boot/grub2/grub.cfg | 2 +- 78 files changed, 7031 insertions(+), 9370 deletions(-) delete mode 100644 arch/all-pc/boot/grub-tools/Install-grub.c delete mode 100644 arch/all-pc/boot/grub-tools/mmakefile.src rewrite arch/m68k-amiga/hidd/amigavideo/amigavideo_hiddclass.c (61%) rewrite arch/m68k-amiga/hidd/amigavideo/chipset.c (68%) rewrite arch/m68k-amiga/hidd/keyboard/kbd_init.c (89%) copy arch/m68k-amiga/hidd/keyboard/{kbd_init.c => startup.c} (93%) rewrite arch/m68k-amiga/hidd/mouse/mouse_init.c (85%) copy arch/m68k-amiga/hidd/mouse/{mouse_init.c => startup.c} (94%) delete mode 100644 arch/m68k-amiga/hidd/p96gfx/mmakefile.src delete mode 100644 arch/m68k-amiga/hidd/p96gfx/p96call.c delete mode 100644 arch/m68k-amiga/hidd/p96gfx/p96gfx_bitmap.h delete mode 100644 arch/m68k-amiga/hidd/p96gfx/p96gfx_bitmapclass.c delete mode 100644 arch/m68k-amiga/hidd/p96gfx/p96gfx_card.c delete mode 100644 arch/m68k-amiga/hidd/p96gfx/p96gfx_hidd.h delete mode 100644 arch/m68k-amiga/hidd/p96gfx/p96gfx_hiddclass.c delete mode 100644 arch/m68k-amiga/hidd/p96gfx/p96gfx_intern.h delete mode 100644 arch/m68k-amiga/hidd/p96gfx/p96gfx_rtg.c delete mode 100644 arch/m68k-amiga/hidd/p96gfx/p96gfx_startup.c create mode 100644 arch/m68k-amiga/hidd/uaegfx/mmakefile.src create mode 100644 arch/m68k-amiga/hidd/uaegfx/p96call.c rename arch/m68k-amiga/hidd/{p96gfx => uaegfx}/p96call.h (100%) create mode 100644 arch/m68k-amiga/hidd/uaegfx/startup.c rename arch/m68k-amiga/hidd/{p96gfx/p96gfx.conf => uaegfx/uaegfx.conf} (53%) create mode 100644 arch/m68k-amiga/hidd/uaegfx/uaegfx_bitmap.h create mode 100644 arch/m68k-amiga/hidd/uaegfx/uaegfx_bitmapclass.c create mode 100644 arch/m68k-amiga/hidd/uaegfx/uaegfx_hidd.h create mode 100644 arch/m68k-amiga/hidd/uaegfx/uaegfx_hiddclass.c create mode 100644 arch/m68k-amiga/hidd/uaegfx/uaegfx_intern.h create mode 100644 arch/m68k-amiga/hidd/uaegfx/uaertg.c rename arch/m68k-amiga/hidd/{p96gfx/p96gfx_rtg.h => uaegfx/uaertg.h} (77%) diff --git a/arch/all-hosted/libs/hostgl/mmakefile.src b/arch/all-hosted/libs/hostgl/mmakefile.src index d37c871ea4..20fe525cef 100644 --- a/arch/all-hosted/libs/hostgl/mmakefile.src +++ b/arch/all-hosted/libs/hostgl/mmakefile.src @@ -5,9 +5,10 @@ include $(SRCDIR)/config/aros.cfg -#MM- workbench-libs-complete : workbench-libs-hostgl-$(OPT_HOST_X11_HOSTGL) +#MM- workbench-libs-complete : workbench-libs-hostgl-$(AROS_TARGET_ARCH)-$(AROS_TARGET_CPU) -#MM- workbench-libs-hostgl-yes : workbench-libs-hostgl +#MM- workbench-libs-hostgl-linux-i386 : workbench-libs-hostgl +#MM- workbench-libs-hostgl-linux-x86_64 : workbench-libs-hostgl #MM workbench-libs-hostgl : includes diff --git a/arch/all-pc/acpitool/catalogs/french.ct b/arch/all-pc/acpitool/catalogs/french.ct index 1fdd5c20cd..e621733107 100644 --- a/arch/all-pc/acpitool/catalogs/french.ct +++ b/arch/all-pc/acpitool/catalogs/french.ct @@ -1,20 +1,20 @@ -## version $VER: acpitool.catalog 2.0 (31.3.2019) +## version $VER: acpitool.catalog 1.1 (26.10.2011) ## language français ## codeset 0 ; ; ; MSG_TITLE -Outil ACPI +ACPI Tool ; MSG_WINTITLE -Outil ACPI +ACPI Tool ; MSG_DESCRIPTION -Interrogation et gestion de l'ACPI +Requètes et gestion de l'ACPI ; MSG_ERROR_LOCALE -Impossible d'ouvrir locale +Can't open locale ; MSG_ERROR_OK Ok @@ -38,7 +38,7 @@ MSG_OEM_ID Revendeur ; MSG_OEM_TABLE_ID -Table revendeur +Table Revendeur ; MSG_CREATOR_ID Constructeur @@ -47,10 +47,10 @@ MSG_PM_PROFILE Profil système préféré ; MSG_SCI_INT -Interruption de contrôle du système (SCI) +Interruption SCI ; MSG_SMI_CMD -Registre de commande SMI (interruptions de gestion du système) +Registre de commande SMI ; MSG_ACPI_ENABLE Commande d'activation ACPI @@ -74,23 +74,23 @@ Pas du cache CPU ;CPU Cache flush stride ; MSG_RTC_DAY_ALARM -Décalage quotidien de l'horloge temps réel +Décalage de l'alarme RTC quotidienne ;RTC alarm day offset ; MSG_RTC_MON_ALARM -Décalage mensuel de l'horloge temps réel +Décalage de l'alarme RTC mensuelle ;RTC alarm month offset ; MSG_RTC_CENTURY -Décalage sur un siècle de l'horloge temps réel +Décalage RTC sur un siècle ;RTC century offset ; MSG_RESET_REG -Adresse du registre de réinitialisation +Addresse du registre de R.A.Z. ;Reset register address ; MSG_RESET_VAL -Valeur de réinitialisation +Valeur de R.A.Z. ;Reset value ; MSG_UNKNOWN_SIZE @@ -137,7 +137,7 @@ MSG_PC_FLAGS Drapeaux architecture PC ; MSG_FF_FLAGS -Drapeaux fonctionnalités fixes +Drapeaux fonctionalités fixes ;Fixed Feature flags ; MSG_LAPIC_ADDR @@ -145,7 +145,7 @@ Adresse de l'APIC locale ;Local APIC address ; MSG_PCAT_COMPAT -Dispose du PIC 8259 PC-AT +Muni du PIC 8259 PC-AT ;Has 8259 PC-AT PIC ; MSG_LOCAL_APIC @@ -153,11 +153,11 @@ APIC locale ;Local APIC ; MSG_CPU_ID -Identificateur ACPI du processeur +ACPI ID processeur ;ACPI Processor ID ; MSG_LAPIC_ID -Identificateur de l'APIC locale +Id APIC locale ;Local APIC ID ; MSG_ENABLED @@ -172,24 +172,24 @@ MSG_ID ID ; MSG_ADDRESS -Adresse +Addresse ; MSG_IRQ_BASE -Base d'interruptions matérielles (IRQ) globale du système +Base IRQ globale au système ;Global system IRQ base ; MSG_INT_SRC_OVR -Consigne de la source d'interruptions +Consigne int. source ;Interrupt source override ; MSG_BUS Bus ; MSG_BUS_IRQ -Bus d'interruptions matérielles (IRQ) +Bus IRQ ; MSG_GLOBAL_IRQ -Interruption matérielle (IRQ) système globale +IRQ système globale ; MSG_POLARITY Polarité @@ -198,19 +198,19 @@ MSG_TRIGGER Bascule ; MSG_NMI_SRC -Source d'interruptions non masquables (NMI) +Source NMI ; MSG_LAPIC_NMI NMI APIC locale ; MSG_DEST_ID -Identificateur ACPI du processeur destination +ID ACPI processeur destination ; MSG_ALL Tout ; MSG_LINT -Entrée d'interruption locale +Entrée d'int. locale ;Local interrupt input ; MSG_LAPIC_ADDR_OVR @@ -231,11 +231,11 @@ MSG_LSAPIC_EID EID SAPIC locale ; MSG_PLAT_INT_SRC -Source d'interruptions de plateforme +Source d'int. plateforme ;Platform interrupt source ; MSG_PLAT_INT_TYPE - Type d'interruption + Type d'int. ; Interrupt type ; MSG_DEST_LSAPIC_ID @@ -247,11 +247,11 @@ EID LSAPIC destination ;Destination LSAPIC EID ; MSG_IOSAPIC_VECTOR -Vecteur SAPIC d'E/S +Vector SAPIC d'E/S ;I/O SAPIC vector ; MSG_CPEI_PROC_OVR -Consigne du processeur d'interruption CPE +Consigne d'int. CPE du processeur ;CPE interrupt processor override ; MSG_LOCAL_X2APIC @@ -271,7 +271,7 @@ NMI X2APIC ;X2APIC NMI ; MSG_UNKNOWN_ENTRY -Entrée inconnue (%u), %u octets +Entrée inconnnue (%u), %u octets ;Unknown entry (%u), %u bytes ; MSG_RSDP_ADDR @@ -286,7 +286,7 @@ R ;ACPI Revision ; MSG_HW_REVISION -Révision matérielle +Révision matériel ;Hardware Revision ; MSG_NUM_COMPARATORS @@ -294,11 +294,11 @@ Nombre de comparateurs ;Number of comparators ; MSG_64BIT_COUNTER -Compteur 64 bits +Compteur 64-bits ;64-bit counter ; MSG_LEGACY_REPLACEMENT -Compatibilité ascendante +Capable de remplacement ;Capable d'héritage ; MSG_PCI_VENDOR @@ -314,7 +314,7 @@ Nombre ;Number ; MSG_MIN_TICK -Fréquence minimale de l'horloge +Battement horloge min. ;Minimum clock tick ; MSG_PAGE_PROTECT @@ -326,7 +326,7 @@ Attributs revendeur ;OEM Attributes ; MSG_SHOW_MODE -Afficher : +Montre : ;Show: ; MSG_SAVE_DATA @@ -368,7 +368,7 @@ MSG_MWH mWh ; MSG_CMD_REG -Registre de commande, d'état +Registre de commande/état ;Command/status register ; MSG_DATA_REG @@ -386,20 +386,4 @@ Bit GPE SCI MSG_NAMESPACE_ID ID espace de nommage ;Namespace ID -; -MSG_MCFG_BASE_ADDRESS -Adresse de base -;Base address -; -MSG_MCFG_SEGMENT -Numéro de groupe du segment PCI -;PCI segment group number -; -MSG_MCFG_START_BUS_NUMBER -Numéro du premier bus PCI -;Starting PCI Bus number -; -MSG_MCFG_END_BUS_NUMBER -Numéro du dernier bus PCI -;Final PCI Bus number -; +; \ No newline at end of file diff --git a/arch/all-pc/acpitool/catalogs/mmakefile.src b/arch/all-pc/acpitool/catalogs/mmakefile.src index 6011c93d14..1ddc182e97 100644 --- a/arch/all-pc/acpitool/catalogs/mmakefile.src +++ b/arch/all-pc/acpitool/catalogs/mmakefile.src @@ -1,9 +1,9 @@ -# Copyright � 2003, The AROS Development Team. All rights reserved. +# Copyright © 2003, The AROS Development Team. All rights reserved. # $Id$ include $(SRCDIR)/config/aros.cfg -CATALOGS:= french +CATALOGS:= # other catalogs need update to version 2 %build_catalogs mmake=debug-tools-acpitool-catalogs \ diff --git a/arch/all-pc/boot/grub-tools/Install-grub.c b/arch/all-pc/boot/grub-tools/Install-grub.c deleted file mode 100644 index 01eeadb774..0000000000 --- a/arch/all-pc/boot/grub-tools/Install-grub.c +++ /dev/null @@ -1,1154 +0,0 @@ -/* - Copyright © 1995-2009, The AROS Development Team. All rights reserved. - $Id$ -*/ -/****************************************************************************** - - - NAME - - Install-i386-pc - - SYNOPSIS - - DEVICE/A, UNIT/N/K/A, PARTITIONNUMBER=PN/K/N, GRUB/K/A, FORCELBA/S - - LOCATION - - C: - - FUNCTION - - Installs the GRUB bootloader to the bootblock of the specified disk. - - INPUTS - - DEVICE -- Device name (e.g. ata.device) - UNIT -- Unit number - PN -- Partition number (advice: the first AROS FFS partition) - GRUB -- Path to GRUB directory. - FORCELBA -- Force use of LBA mode. - - RESULT - - NOTES - - EXAMPLE - - install-i386-pc DEVICE ata.device UNIT 0 PN 1 grub dh0:boot/grub - - BUGS - - SEE ALSO - - Partition, Sys:System/Format - - INTERNALS - -******************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG 0 -#include - -/* Defines for grub data */ -/* Stage 1 pointers */ -#define MBR_BPBEND 0x3e -#define GRUB_BOOT_DRIVE 0x40 -#define GRUB_FORCE_LBA 0x41 -#define GRUB_STAGE2_SECTOR 0x44 -#define MBR_PARTSTART 0x1be -#define MBR_PARTEND 0x1fe -/* Stage 2 pointers */ - -/* BIOS drive flag */ -#define BIOS_HDISK_FLAG 0x80 - -#define MBR_MAX_PARTITIONS 4 -#define MBRT_EXTENDED 0x05 -#define MBRT_EXTENDED2 0x0f - -struct Volume { - struct MsgPort *mp; - struct IOExtTD *iotd; - ULONG readcmd; - ULONG writecmd; - ULONG startblock; - ULONG countblock; - CONST_STRPTR device; - ULONG unitnum; - UWORD SizeBlock; - UBYTE flags; - BYTE partnum; - ULONG *blockbuffer; -}; - -#define VF_IS_TRACKDISK (1<<0) -#define VF_IS_RDB (1<<1) - -struct BlockNode { - ULONG sector; - UWORD count; - UWORD seg_adr; -}; - -const TEXT version[] = "$VER: Install-i386-pc 41.2 (4.6.2009)"; - -char *template = - "DEVICE/A," - "UNIT/N/K/A," - "PARTITIONNUMBER=PN/K/N," /* Partition whose boot block we should install stage1 in */ - "GRUB/K/A," - "FORCELBA/S"; -IPTR myargs[7] = {0,0,0,0,0,0}; - -struct FileSysStartupMsg *getDiskFSSM(STRPTR path) { -struct DosList *dl; -struct DeviceNode *dn; -char dname[32]; -UBYTE i; - -D(bug("[install-i386] getDiskFSSM('%s')\n", path)); - - for (i=0;(path[i]) && (path[i]!=':');i++) - dname[i] = path[i]; - if (path[i] == ':') - { - dname[i] = 0; - dl = LockDosList(LDF_READ); - if (dl) - { - dn = (struct DeviceNode *)FindDosEntry(dl, dname, LDF_DEVICES); - UnLockDosList(LDF_READ); - if (dn) - { - dname[i] = ':'; - dname[i + 1] = '\0'; - if (IsFileSystem(dname)) - { - return (struct FileSysStartupMsg *)BADDR(dn->dn_Startup); - } - else - Printf("device '%s' doesn't contain a file system\n", dname); - } - else - PrintFault(ERROR_OBJECT_NOT_FOUND, dname); - } - } - else - Printf("'%s' doesn't contain a device name\n",path); - return 0; -} - -void fillGeometry(struct Volume *volume, struct DosEnvec *de) { -ULONG spc; - -D(bug("[install-i386] fillGeometry(%x)\n", volume)); - - spc = de->de_Surfaces*de->de_BlocksPerTrack; - volume->SizeBlock = de->de_SizeBlock; - volume->startblock = de->de_LowCyl*spc; - volume->countblock =((de->de_HighCyl-de->de_LowCyl+1)*spc)-1+de->de_Reserved; -} - -void nsdCheck(struct Volume *volume) { -struct NSDeviceQueryResult nsdq; -UWORD *cmdcheck; - -D(bug("[install-i386] nsdCheck(%x)\n", volume)); - - if ( - ( - (volume->startblock+volume->countblock)* /* last block */ - ((volume->SizeBlock<<2)/512) /* 1 portion (block) equals 512 (bytes) */ - )>8388608) - { - nsdq.SizeAvailable=0; - nsdq.DevQueryFormat=0; - volume->iotd->iotd_Req.io_Command=NSCMD_DEVICEQUERY; - volume->iotd->iotd_Req.io_Data=&nsdq; - volume->iotd->iotd_Req.io_Length=sizeof(struct NSDeviceQueryResult); - if (DoIO((struct IORequest *)&volume->iotd->iotd_Req)==IOERR_NOCMD) - { - Printf("Device doesn't understand NSD-Query\n"); - } - else - { - if ( - (volume->iotd->iotd_Req.io_Actual>sizeof(struct NSDeviceQueryResult)) || - (volume->iotd->iotd_Req.io_Actual==0) || - (volume->iotd->iotd_Req.io_Actual!=nsdq.SizeAvailable) - ) - { - Printf("WARNING wrong io_Actual using NSD\n"); - } - else - { - if (nsdq.DeviceType != NSDEVTYPE_TRACKDISK) - Printf("WARNING no trackdisk type\n"); - for (cmdcheck=nsdq.SupportedCommands;*cmdcheck;cmdcheck++) - { - if (*cmdcheck == NSCMD_TD_READ64) - volume->readcmd = NSCMD_TD_READ64; - if (*cmdcheck == NSCMD_TD_WRITE64) - volume->writecmd = NSCMD_TD_WRITE64; - } - if ( - (volume->readcmd!=NSCMD_TD_READ64) || - (volume->writecmd!=NSCMD_TD_WRITE64) - ) - Printf("WARNING no READ64/WRITE64\n"); - } - } - } -} - - -struct Volume *initVolume(STRPTR device, ULONG unit, ULONG flags, struct DosEnvec *de) { -struct Volume *volume; -LONG error=0; - -D(bug("[install-i386] initVolume(%s:%d)\n", device, unit)); - - volume = AllocVec(sizeof(struct Volume), MEMF_PUBLIC | MEMF_CLEAR); - if (volume) - { - volume->mp = CreateMsgPort(); - if (volume->mp) - { - volume->iotd = (struct IOExtTD *)CreateIORequest(volume->mp, sizeof(struct IOExtTD)); - if (volume->iotd) - { - volume->blockbuffer = AllocVec(de->de_SizeBlock<<2, MEMF_PUBLIC | MEMF_CLEAR); - if (volume->blockbuffer) - { - if ( - OpenDevice - ( - device, - unit, - (struct IORequest *)volume->iotd, - flags - ) == 0 - ) - { - if (strcmp(device, "trackdisk.device")==0) - volume->flags |= VF_IS_TRACKDISK; - else - volume->flags |= VF_IS_RDB; /* just assume we have RDB */ - volume->readcmd = CMD_READ; - volume->writecmd = CMD_WRITE; - volume->device = device; - volume->unitnum = unit; - fillGeometry(volume, de); - nsdCheck(volume); - return volume; - } - else - error = ERROR_NO_FREE_STORE; - FreeVec(volume->blockbuffer); - } - else - error = ERROR_NO_FREE_STORE; - DeleteIORequest((struct IORequest *)volume->iotd); - } - else - error = ERROR_NO_FREE_STORE; - DeleteMsgPort(volume->mp); - } - else - error = ERROR_NO_FREE_STORE; - FreeVec(volume); - } - else - error = ERROR_NO_FREE_STORE; - PrintFault(error, NULL); - return 0; -} - -void uninitVolume(struct Volume *volume) -{ - -D(bug("[install-i386] uninitVolume(%x)\n", volume)); - - CloseDevice((struct IORequest *)volume->iotd); - FreeVec(volume->blockbuffer); - DeleteIORequest((struct IORequest *)volume->iotd); - DeleteMsgPort(volume->mp); - FreeVec(volume); -} - -ULONG readwriteBlock - ( - struct Volume *volume, - ULONG block, APTR buffer, ULONG length, - ULONG command - ) -{ -UQUAD offset; -ULONG retval=0; - -D(bug("[install-i386] readwriteBlock(vol:%x, block:%d, %d bytes)\n", volume, block, length)); - - volume->iotd->iotd_Req.io_Command = command; - volume->iotd->iotd_Req.io_Length = length; - volume->iotd->iotd_Req.io_Data = buffer; - offset = (UQUAD)(volume->startblock+block)*(volume->SizeBlock<<2); - volume->iotd->iotd_Req.io_Offset = offset & 0xFFFFFFFF; - volume->iotd->iotd_Req.io_Actual = offset>>32; - retval = DoIO((struct IORequest *)&volume->iotd->iotd_Req); - if (volume->flags & VF_IS_TRACKDISK) - { - volume->iotd->iotd_Req.io_Command = TD_MOTOR; - volume->iotd->iotd_Req.io_Length = 0; - DoIO((struct IORequest *)&volume->iotd->iotd_Req); - } - return retval; -} - -BOOL isvalidFileSystem(struct Volume *volume, STRPTR device, ULONG unit) { -BOOL retval = FALSE; -struct PartitionBase *PartitionBase; -struct PartitionHandle *ph; - -D(bug("[install-i386] isvalidFileSystem(%x, %s, %d)\n", volume, device, unit)); - - if (readwriteBlock(volume, 0, volume->blockbuffer, 512, volume->readcmd)) - { - Printf("Read Error\n"); - return FALSE; - } - if ( - ((AROS_BE2LONG(volume->blockbuffer[0]) & 0xFFFFFF00)!=0x444F5300) || - ((AROS_BE2LONG(volume->blockbuffer[0]) & 0xFF) == 0) - ) - { - /* first block has no DOS\x so we don't have RDB for sure */ - volume->flags &= ~VF_IS_RDB; - if (readwriteBlock(volume, 1, volume->blockbuffer, 512, volume->readcmd)) - { - Printf("Read Error\n"); - return FALSE; - } - if ( - ((AROS_BE2LONG(volume->blockbuffer[0]) & 0xFFFFFF00)!=0x444F5300) || - ((AROS_BE2LONG(volume->blockbuffer[0]) & 0xFF) == 0) - ) - return FALSE; - } - volume->partnum = -1; - PartitionBase = (struct PartitionBase *)OpenLibrary("partition.library", 1); - if (PartitionBase) - { - ph = OpenRootPartition(device, unit); - if (ph) - { - if (OpenPartitionTable(ph) == 0) - { - struct TagItem tags[3]; - IPTR type; - - tags[1].ti_Tag = TAG_DONE; - tags[0].ti_Tag = PTT_TYPE; - tags[0].ti_Data = (STACKIPTR)&type; - GetPartitionTableAttrs(ph, tags); - if (type == PHPTT_MBR) - { - struct PartitionHandle *pn; - struct DosEnvec de; - struct PartitionHandle *extph = NULL; - struct PartitionType ptype = {{0}}; - - tags[0].ti_Tag = PT_DOSENVEC; - tags[0].ti_Data = (STACKIPTR)&de; - tags[1].ti_Tag = PT_TYPE; - tags[1].ti_Data = (STACKIPTR)&ptype; - tags[2].ti_Tag = TAG_DONE; - pn = (struct PartitionHandle *)ph->table->list.lh_Head; - while (pn->ln.ln_Succ) - { - ULONG scp; - - GetPartitionAttrs(pn, tags); - if (ptype.id[0] == MBRT_EXTENDED || ptype.id[0] == MBRT_EXTENDED2) - extph = pn; - else - { - scp = de.de_Surfaces*de.de_BlocksPerTrack; - if ( - (volume->startblock>=(de.de_LowCyl*scp)) && - (volume->startblock<=(((de.de_HighCyl+1)*scp)-1)) - ) - break; - } - pn = (struct PartitionHandle *)pn->ln.ln_Succ; - } - if (pn->ln.ln_Succ) - { - tags[0].ti_Tag = PT_POSITION; - tags[0].ti_Data = (STACKIPTR)&type; - tags[1].ti_Tag = TAG_DONE; - GetPartitionAttrs(pn, tags); - volume->partnum = (UBYTE)type; - retval = TRUE; - D(bug("[install-i386] Primary partition found: partnum=%ld\n", volume->partnum)); - } - else if (extph != NULL) - { - if (OpenPartitionTable(extph) == 0) - { - tags[0].ti_Tag = PTT_TYPE; - tags[0].ti_Data = (STACKIPTR)&type; - tags[1].ti_Tag = TAG_DONE; - GetPartitionTableAttrs(extph, tags); - if (type == PHPTT_EBR) - { - tags[0].ti_Tag = PT_DOSENVEC; - tags[0].ti_Data = (STACKIPTR)&de; - tags[1].ti_Tag = TAG_DONE; - pn = (struct PartitionHandle *)extph->table->list.lh_Head; - while (pn->ln.ln_Succ) - { - ULONG offset, scp; - - offset = extph->de.de_LowCyl - * extph->de.de_Surfaces - * extph->de.de_BlocksPerTrack; - GetPartitionAttrs(pn, tags); - scp = de.de_Surfaces*de.de_BlocksPerTrack; - if ( - (volume->startblock>=offset+(de.de_LowCyl*scp)) && - (volume->startblock<=offset+(((de.de_HighCyl+1)*scp)-1)) - ) - break; - pn = (struct PartitionHandle *)pn->ln.ln_Succ; - } - if (pn->ln.ln_Succ) - { - tags[0].ti_Tag = PT_POSITION; - tags[0].ti_Data = (STACKIPTR)&type; - GetPartitionAttrs(pn, tags); - volume->partnum = MBR_MAX_PARTITIONS + (UBYTE)type; - retval = TRUE; - D(bug("[install-i386] Logical partition found: partnum=%ld\n", volume->partnum)); - } - } - ClosePartitionTable(extph); - } - } - } - else - { - if (type == PHPTT_RDB) - { - /* just use whole hard disk */ - retval = TRUE; - } - else - Printf("only MBR and RDB partition tables are supported\n"); - } - ClosePartitionTable(ph); - } - else - { - /* just use whole hard disk */ - retval = TRUE; - } - CloseRootPartition(ph); - } - else - Printf("Error OpenRootPartition(%s,%lu)\n", device, (long)unit); - CloseLibrary((struct Library *)PartitionBase); - } - else - Printf("Couldn't open partition.library\n"); - return retval; -} - -struct Volume *getGrubStageVolume - ( - STRPTR device, - ULONG unit, - ULONG flags, - struct DosEnvec *de - ) -{ -struct Volume *volume; - - volume = initVolume(device, unit, flags, de); - -D(bug("[install-i386] getGrubStageVolume(): volume=%x\n", volume)); - - if (volume) - { - if (isvalidFileSystem(volume, device, unit)) - return volume; - else - { - Printf("stage2 is on an unsupported file system\n"); - PrintFault(ERROR_OBJECT_WRONG_TYPE, NULL); - } - uninitVolume(volume); - } - return 0; -} - -BOOL isvalidPartition - ( - STRPTR device, - ULONG unit, - LONG *pnum, - struct DosEnvec *de - ) -{ -struct PartitionBase *PartitionBase; -struct PartitionHandle *ph; -ULONG type; -BOOL retval=FALSE; - -D(bug("[install-i386] isvalidPartition(%s:%d, part:%d)\n", device, unit, pnum)); - - PartitionBase = (struct PartitionBase *)OpenLibrary("partition.library", 1); - if (PartitionBase) - { - ph = OpenRootPartition(device, unit); - if (ph) - { - struct TagItem tags[2]; - - tags[1].ti_Tag = TAG_DONE; - /* is there a partition table? */ - if (OpenPartitionTable(ph) == 0) - { - if (pnum) - { - /* install into partition bootblock */ - tags[0].ti_Tag = PTT_TYPE; - tags[0].ti_Data = (STACKIPTR)&type; - GetPartitionTableAttrs(ph, tags); - if (type == PHPTT_MBR) - { - struct PartitionHandle *pn; - - /* search for partition */ - tags[0].ti_Tag = PT_POSITION; - tags[0].ti_Data = (STACKIPTR)&type; - pn = (struct PartitionHandle *)ph->table->list.lh_Head; - while (pn->ln.ln_Succ) - { - GetPartitionAttrs(pn, tags); - if (type == *pnum) - break; - pn = (struct PartitionHandle *)pn->ln.ln_Succ; - } - if (pn->ln.ln_Succ) - { - struct PartitionType ptype; - - /* is it an AROS partition? */ - tags[0].ti_Tag = PT_TYPE; - tags[0].ti_Data = (STACKIPTR)&ptype; - GetPartitionAttrs(pn, tags); - if (ptype.id[0] == 0x30) - { - tags[0].ti_Tag = PT_DOSENVEC; - tags[0].ti_Data = (STACKIPTR)de; - GetPartitionAttrs(pn, tags); - retval = TRUE; - } - else - Printf("partition is not of type AROS (0x30)\n"); - } - else - { - Printf - ( - "partition %ld not found on device %s unit %lu\n", - (long)*pnum, device, (long)unit - ); - } - } - else - Printf("you can only install in partitions which are MBR partitioned\n"); - } - else - { - /* install into MBR */ - tags[0].ti_Tag = PTT_TYPE; - tags[0].ti_Data = (STACKIPTR)&type; - GetPartitionTableAttrs(ph, tags); - if ((type == PHPTT_MBR) || (type == PHPTT_RDB)) - { - tags[0].ti_Tag = PT_DOSENVEC; - tags[0].ti_Data = (STACKIPTR)de; - GetPartitionAttrs(ph, tags); - retval = TRUE; - } - else - Printf("partition table type must be either MBR or RDB\n"); - } - ClosePartitionTable(ph); - } - else - { - /* FIXME: GetPartitionAttr() should always work for root partition */ - CopyMem(&ph->de, de, sizeof(struct DosEnvec)); - retval = TRUE; - } - CloseRootPartition(ph); - } - else - Printf("Error OpenRootPartition(%s,%lu)\n", device, (long)unit); - CloseLibrary((struct Library *)PartitionBase); - } - else - Printf("Couldn't open partition.library\n"); - return retval; -} - -struct Volume *getBBVolume(STRPTR device, ULONG unit, LONG *partnum) { -struct Volume *volume; -struct DosEnvec de; - -D(bug("[install-i386] getBBVolume(%s:%d, %d)\n", device, unit, partnum)); - - if (isvalidPartition(device, unit, partnum, &de)) - { - volume = initVolume(device, unit, 0, &de); - volume->partnum = partnum ? *partnum : -1; - readwriteBlock(volume, 0, volume->blockbuffer, 512, volume->readcmd); - if (AROS_BE2LONG(volume->blockbuffer[0]) != IDNAME_RIGIDDISK) - { - memset(volume->blockbuffer,0x00, 446); /* Clear the boot sector region! */ - return volume; - } - else - Printf("no space for bootblock (RDB is on block 0)\n"); - } - return NULL; -} - -ULONG collectBlockList - ( - struct Volume *volume, - ULONG block, - struct BlockNode *blocklist - ) -{ -ULONG retval, first_block; -WORD blk_count,count; -UWORD i; - -D(bug("[install-i386] collectBlockList(%x, %d, %x)\n", volume, block, blocklist)); - - /* TODO: logical/physical blocks */ - /* - initialze stage2-blocklist - (it is NULL-terminated) - */ -// for (blk_count=-1;blocklist[blk_count].sector!=0;blk_count--) -// blocklist[blk_count].sector = 0; - - memset((char *)&blocklist[-20],0x00, 20*sizeof(struct BlockNode)); /* Clear the stage2 sector pointers region! */ -D(bug("[install-i386] collectBlockList: Cleared sector list (20 entries) [start: %x, end %x]\n", &blocklist[-20], &blocklist[-1])); - - /* - the first block of stage2 will be stored in stage1 - so skip the first filekey in the first loop - */ - /* FIXME: Block read twice */ - retval=readwriteBlock - ( - volume, block, volume->blockbuffer, volume->SizeBlock<<2, - volume->readcmd - ); - if (retval) - { -D(bug("[install-i386] collectBlockList: ERROR reading block (error: %ld\n", retval)); - Printf("ReadError %lu\n", (long)retval); - return 0; - } - - i = volume->SizeBlock - 52; - first_block = AROS_BE2LONG(volume->blockbuffer[volume->SizeBlock-51]); - blk_count=0; - -D(bug("[install-i386] collectBlockList: First block @ %x, i:%d\n", first_block, i)); - - - do - { - retval=readwriteBlock - ( - volume, block, volume->blockbuffer, volume->SizeBlock<<2, - volume->readcmd - ); - if (retval) - { -D(bug("[install-i386] collectBlockList: ERROR reading block (error: %ld)\n", retval)); - Printf("ReadError %lu\n", (long)retval); - return 0; - } -D(bug("[install-i386] collectBlockList: read block %lx, i = %d\n", block, i)); - while ((i>=6) && (volume->blockbuffer[i])) - { -D(bug("[install-i386] collectBlockList: i = %d\n", i)); - /* - if current sector follows right after last sector - then we don't need a new element - */ - if ( - (blocklist[blk_count].sector) && - ((blocklist[blk_count].sector+blocklist[blk_count].count)== - AROS_BE2LONG(volume->blockbuffer[i])) - ) - { - blocklist[blk_count].count += 1; -D(bug("[install-i386] collectBlockList: sector %d follows previous - increasing count of block %d to %d\n", i, blk_count, blocklist[blk_count].count)); - } - else - { - blk_count--; /* decrement first */ -D(bug("[install-i386] collectBlockList: store new block (%d)\n", blk_count)); - if (blocklist[blk_count-1].sector != 0) - { -D(bug("[install-i386] collectBlockList: ERROR: out of block space at sector %d, block %d\n", i, blk_count)); - Printf("There is no more space to save blocklist in stage2\n"); - return 0; - } -D(bug("[install-i386] collectBlockList: storing sector pointer for %d in block %d\n", i, blk_count)); - blocklist[blk_count].sector = AROS_BE2LONG(volume->blockbuffer[i]); - blocklist[blk_count].count = 1; - } - i--; - } - i = volume->SizeBlock - 51; - block = AROS_BE2LONG(volume->blockbuffer[volume->SizeBlock - 2]); -D(bug("[install-i386] collectBlockList: next block %d, i = %d\n", block, i)); - } while (block); - /* - blocks in blocklist are relative to the first - sector of the HD (not partition) - */ -D(bug("[install-i386] collectBlockList: successfully updated pointers for %d blocks\n", blk_count)); - - i = 0; - for (count=-1;count>=blk_count;count--) - { - blocklist[count].sector += volume->startblock; - blocklist[count].seg_adr = 0x820 + (i*32); - i += blocklist[count].count; -D(bug("[install-i386] collectBlockList: correcting block %d for partition start\n", count)); -D(bug("[install-i386] collectBlockList: sector : %x seg_adr : %x\n", blocklist[count].sector, blocklist[count].seg_adr)); - } - return first_block; -} - -void copyRootPath(char *dst, char *rpdos, BOOL isRDB) { - -D(bug("[install-i386] copyRootPath()\n")); - - if (isRDB) - { - /* we have an RDB so use devicename */ - *dst++ = '/'; - while ((*rpdos) && (*rpdos!=':')) - *dst++ = *rpdos++; - } - else - { - while ((*rpdos) && (*rpdos!=':')) - rpdos++; - } - rpdos++; /* skip colon */ - *dst++ = '/'; - /* append path */ - while (*rpdos) - *dst++ = *rpdos++; - if (dst[-1] == '/') - dst[-1] = 0; - else - *dst = 0; -} - -/* Convert a unit number into a drive number as understood by GRUB */ -UWORD getDriveNumber(CONST_STRPTR device, ULONG unit) -{ - struct PartitionHandle *ph; - ULONG i; - UWORD hd_count = 0; - - for (i = 0; i < unit; i++) - { - ph = OpenRootPartition(device, i); - if (ph != NULL) - { - hd_count++; - CloseRootPartition(ph); - } - } - - return hd_count; -} - -UBYTE *memstr(UBYTE *mem, UBYTE *str, LONG len) { -UBYTE *next; -UBYTE *search; -LONG left; - - while (len) - { - len--; - if (*mem++ == *str) - { - next = mem; - search = str+1; - left = len; - while ((*search) && (left) && (*next++ == *search++)) - left--; - if (*search == 0) - return mem-1; - } - } - return 0; -} - -BOOL writeStage2 - ( - BPTR fh, - UBYTE *buffer, - STRPTR grubpath, - struct Volume *volume - ) -{ -BOOL retval = FALSE; -char *menuname; - -D(bug("[install-i386] writeStage2(%x)\n", volume)); - - if (Seek(fh, 0, OFFSET_BEGINNING) != -1) - { - /* write back first block */ - if (Write(fh, buffer, 512)==512) - { - /* read second stage2 block */ - if (Read(fh, buffer, 512) == 512) - { - /* set partition number where stage2 is on */ - buffer[8] = 0xFF; - buffer[9] = 0xFF; - buffer[10] = volume->partnum; - buffer[11] = 0; - /* get ptr to version string */ - menuname = buffer+18; - while (*menuname++); /* skip version string */ - copyRootPath(menuname, grubpath, volume->flags & VF_IS_RDB); - strcat(menuname, "/menu.lst"); - /* write second stage2 block back */ - if (Seek(fh, -512, OFFSET_CURRENT) != -1) - { - if (Write(fh, buffer, 512) == 512) - { - retval = TRUE; - } - else - Printf("%s: Write Error\n", menuname); - } - else - Printf("%s: Seek Error\n", menuname); - } - else - Printf("Read Error\n"); - } - else - Printf("Write Error\n"); - } - else - PrintFault(IoErr(), NULL); - return retval; -} - -ULONG changeStage2 - ( - STRPTR grubpath, /* path of grub dir */ - struct Volume *volume, /* volume stage2 is on */ - ULONG *buffer /* a buffer of at least 512 bytes */ - ) -{ -ULONG block = 0; -struct FileInfoBlock fib; -BPTR fh; -char stage2path[256]; - -D(bug("[install-i386] changeStage2(%x)\n", volume)); - - AddPart(stage2path, grubpath, 256); - AddPart(stage2path, "stage2", 256); - fh = Open(stage2path, MODE_OLDFILE); - if (fh) - { - if (ExamineFH(fh, &fib)) - { - if (Read(fh, buffer, 512) == 512) - { - /* - get and store all blocks of stage2 in first block of stage2 - first block of stage2 will be returned - */ - block = collectBlockList - (volume, fib.fib_DiskKey, (struct BlockNode *)&buffer[128]); - - if (block) - { - if (!writeStage2(fh, (UBYTE *)buffer, grubpath, volume)) - block = 0; - } - } - else - Printf("%s: Read Error\n", stage2path); - } - else - PrintFault(IoErr(), stage2path); - Close(fh); - } - else - PrintFault(IoErr(), stage2path); - return block; -} - -BOOL writeStage1 - ( - STRPTR stage1path, - struct Volume *volume, - struct Volume *s2vol, - ULONG block, /* first block of stage2 file */ - ULONG unit - ) -{ -BOOL retval = FALSE; -LONG error = 0; -BPTR fh; - -D(bug("[install-i386] writeStage1(%x)\n", volume)); - - fh = Open(stage1path, MODE_OLDFILE); - if (fh) - { - if (Read(fh, volume->blockbuffer, 512) == 512) - { - /* install into MBR ? */ - if ((volume->startblock == 0) && (!(volume->flags & VF_IS_TRACKDISK))) - { -D(bug("[install-i386] writeStage1: Install to HARDDISK\n")); - // read old MBR - error = readwriteBlock - (volume, 0, s2vol->blockbuffer, 512, volume->readcmd); - -D(bug("[install-i386] writeStage1: MBR Buffer @ %x\n", volume->blockbuffer)); -D(bug("[install-i386] writeStage1: Copying MBR BPB to %x\n", (char *)volume->blockbuffer + 0x04)); - // copy BPB (BIOS Parameter Block) - CopyMem - ( - (APTR)((char *)s2vol->blockbuffer + 0x04), - (APTR)((char *)volume->blockbuffer + 0x04), - (MBR_BPBEND - 4) - ); - // copy partition table - [Overwrites Floppy boot code] -D(bug("[install-i386] writeStage1: Copying MBR Partitions to %x\n", (char *)volume->blockbuffer + MBR_PARTSTART)); - CopyMem - ( - (APTR)((char *)s2vol->blockbuffer + MBR_PARTSTART), - (APTR)((char *)volume->blockbuffer + MBR_PARTSTART), - (MBR_PARTEND - MBR_PARTSTART) - ); - // store the drive num stage2 is stored on - ((char *)volume->blockbuffer)[GRUB_BOOT_DRIVE] = - getDriveNumber(volume->device, unit) | BIOS_HDISK_FLAG; - // Store the stage 2 pointer .. - ULONG * stage2_sector_start = (ULONG *)((char *)volume->blockbuffer + GRUB_STAGE2_SECTOR); -D(bug("[install-i386] writeStage1: writing stage2 pointer @ %x\n", stage2_sector_start)); - stage2_sector_start[0] = block; -D(bug("[install-i386] writeStage1: stage2 pointer = %x\n", stage2_sector_start[0])); - stage2_sector_start[0] += s2vol->startblock; -D(bug("[install-i386] writeStage1: + offset [%d] = %x\n", s2vol->startblock, stage2_sector_start[0])); - - if (myargs[4]!=0) - { -D(bug("[install-i386] writeStage1: Forcing LBA\n")); - ((char *)volume->blockbuffer)[GRUB_FORCE_LBA] = 1; - } - else - { -D(bug("[install-i386] writeStage1: NOT Forcing LBA\n")); - ((char *)volume->blockbuffer)[GRUB_FORCE_LBA] = 0; - } - } - else - { -D(bug("[install-i386] writeStage1: Install to FLOPPY\n")); - } - - if (error == 0) - { - error = readwriteBlock - (volume, 0, volume->blockbuffer, 512, volume->writecmd); - if (error) - Printf("WriteError %lu\n", (long)error); - else - retval = TRUE; - } - else - Printf("WriteError %lu\n", (long)error); - } - else - Printf("%s: Read Error\n", stage1path); - Close(fh); - } - else - PrintFault(IoErr(), stage1path); - return retval; -} - -/* Flushes the cache on the volume containing the specified path. */ -VOID flushFS(CONST TEXT *path) -{ -char devname[256]; -UWORD i; - - for (i = 0; path[i] != ':'; i++) - devname[i] = path[i]; - devname[i++] = ':'; - devname[i] = '\0'; - if (Inhibit(devname, DOSTRUE)) - Inhibit(devname, DOSFALSE); -} - -BOOL installStageFiles - ( - struct Volume *s2vol, /* stage2 volume */ - STRPTR stagepath, /* path to stage* files */ - ULONG unit, /* unit stage2 is on */ - struct Volume *s1vol /* device on which stage1 will be stored */ - ) -{ -BOOL retval = FALSE; -char stagename[256]; -ULONG block; - -D(bug("[install-i386] installStageFiles(%x)\n", s1vol)); - - /* Flush GRUB volume's cache */ - flushFS(stagepath); - - block = changeStage2(stagepath, s2vol, s1vol->blockbuffer); - if (block) - { - AddPart(stagename, stagepath, 256); - AddPart(stagename, "stage1", 256); - if (writeStage1(stagename, s1vol, s2vol, block, unit)) - retval = TRUE; - } - return retval; -} - -int main(int argc, char **argv) { - -struct RDArgs *rdargs; -struct Volume *grubvol; -struct Volume *bbvol; -struct FileSysStartupMsg *fssm; - -D(bug("[install-i386] main()\n")); - - rdargs = ReadArgs(template, myargs, NULL); - if (rdargs) - { -D(bug("[install-i386] FORCELBA = %d\n",myargs[4])); - - fssm = getDiskFSSM((STRPTR)myargs[3]); - if (fssm != NULL) - { - if ( - (strcmp(AROS_BSTR_ADDR(fssm->fssm_Device),(char*)myargs[0])==0) - ) - { - grubvol = getGrubStageVolume - ( - AROS_BSTR_ADDR(fssm->fssm_Device), - fssm->fssm_Unit, - fssm->fssm_Flags, - (struct DosEnvec *)BADDR(fssm->fssm_Environ) - ); - if (grubvol) - { - bbvol=getBBVolume - ( - (STRPTR)myargs[0], - *((LONG *)myargs[1]), - (LONG *)myargs[2] - ); - if (bbvol) - { - ULONG retval=0; - /* - getBBVolume() read block 0 - if the partition directly contains a filesystem - (currently only DOS\x is supported) we have - to move block 0 to block 1 to make space for stage1 - */ - if ( - (grubvol->startblock == bbvol->startblock) && - ((AROS_BE2LONG(bbvol->blockbuffer[0]) & 0xFFFFFF00)==0x444F5300) - ) - { - grubvol->flags &= ~VF_IS_RDB; - retval = readwriteBlock - (bbvol, 0, bbvol->blockbuffer, 512, bbvol->readcmd); - } - if (retval == 0) - { - installStageFiles - ( - grubvol, - (STRPTR)myargs[3], /* grub path (stage1/2) */ - fssm->fssm_Unit, - bbvol - ); - } - else - Printf("Read Error: %lu\n", (long)retval); - uninitVolume(bbvol); - } - uninitVolume(grubvol); - } - } - else - { - Printf - ( - "%s is not on device %s unit %lu\n", - (STRPTR)myargs[3], (STRPTR)myargs[0], (long)*((ULONG *)myargs[1]) - ); - } - } - else - if (fssm) - Printf("kernel path must begin with a device name\n"); - FreeArgs(rdargs); - } - else - PrintFault(IoErr(), argv[0]); - return 0; -} - diff --git a/arch/all-pc/boot/grub-tools/mmakefile.src b/arch/all-pc/boot/grub-tools/mmakefile.src deleted file mode 100644 index e5196917d9..0000000000 --- a/arch/all-pc/boot/grub-tools/mmakefile.src +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright © 2011, The AROS Development Team. All rights reserved. -# $Id$ - -include $(SRCDIR)/config/aros.cfg - -#MM- workbench-c : grub-aros-installer -#MM- workbench-c-quick : grub-aros-installer-quick - -FILES := Install-grub - -USER_CPPFLAGS := -DADATE="\"$(shell date "+%d.%m.%Y")\"" -USER_INCLUDES := -isystem $(SRCDIR)/arch/all-pc/boot/grub-aros/include - -%build_progs mmake=grub-aros-installer \ - files=$(FILES) targetdir=$(AROS_C) \ - uselibs="debug" - -%common diff --git a/arch/all-pc/boot/grub2-aros/grub-2.02-aros.diff b/arch/all-pc/boot/grub2-aros/grub-2.02-aros.diff index d1f996abf2..776a6b49c2 100644 --- a/arch/all-pc/boot/grub2-aros/grub-2.02-aros.diff +++ b/arch/all-pc/boot/grub2-aros/grub-2.02-aros.diff @@ -12,18 +12,6 @@ diff -ruN grub-2.02/grub-core/fs/affs.c grub-2.02.aros/grub-core/fs/affs.c /* Test if the filesystem is a OFS filesystem. */ || !(data->bblock.flags & GRUB_AFFS_FLAG_FFS)) continue; -diff -ruN grub-2.02/grub-core/fs/btrfs.c grub-2.02.aros/grub-core/fs/btrfs.c ---- grub-2.02/grub-core/fs/btrfs.c 2017-04-24 10:16:00.000000000 +0100 -+++ grub-2.02.aros/grub-core/fs/btrfs.c 2017-04-24 12:30:25.000000000 +0100 -@@ -175,7 +175,7 @@ - { - grub_int64_t sec; - grub_uint32_t nanosec; --} __attribute__ ((aligned (4))); -+} GRUB_PACKED; - - struct grub_btrfs_inode - { diff -ruN grub-2.02/grub-core/osdep/aros/getroot.c grub-2.02.aros/grub-core/osdep/aros/getroot.c --- grub-2.02/grub-core/osdep/aros/getroot.c 2015-05-21 16:50:29.000000000 +0100 +++ grub-2.02.aros/grub-core/osdep/aros/getroot.c 2017-04-24 12:30:25.000000000 +0100 @@ -57,49 +45,3 @@ diff -ruN grub-2.02/grub-core/osdep/aros/relpath.c grub-2.02.aros/grub-core/osde #include #include #include -diff -ruN grub-2.02/include/grub/efiemu/runtime.h grub-2.02.aros/include/grub/efiemu/runtime.h ---- grub-2.02/include/grub/efiemu/runtime.h 2015-05-21 16:50:29.000000000 +0100 -+++ grub-2.02.aros/include/grub/efiemu/runtime.h 2019-03-29 16:16:01.449086200 +0000 -@@ -29,7 +29,7 @@ - - struct efi_variable - { -- grub_efi_guid_t guid; -+ grub_efi_packed_guid_t guid; - grub_uint32_t namelen; - grub_uint32_t size; - grub_efi_uint32_t attributes; -diff -ruN grub-2.02/include/grub/gpt_partition.h grub-2.02.aros/include/grub/gpt_partition.h ---- grub-2.02/include/grub/gpt_partition.h 2015-05-21 16:50:29.000000000 +0100 -+++ grub-2.02.aros/include/grub/gpt_partition.h 2019-03-29 16:16:48.443396000 +0000 -@@ -28,7 +28,7 @@ - grub_uint16_t data2; - grub_uint16_t data3; - grub_uint8_t data4[8]; --} __attribute__ ((aligned(8))); -+} GRUB_PACKED; - typedef struct grub_gpt_part_type grub_gpt_part_type_t; - - #define GRUB_GPT_PARTITION_TYPE_EMPTY \ -diff -ruN grub-2.02/util/grub-mkimagexx.c grub-2.02.aros/util/grub-mkimagexx.c ---- grub-2.02/util/grub-mkimagexx.c 2017-04-24 10:16:00.000000000 +0100 -+++ grub-2.02.aros/util/grub-mkimagexx.c 2017-04-24 12:30:25.000000000 +0100 -@@ -832,6 +832,7 @@ - break; - - case R_X86_64_PC32: -+ case R_X86_64_PLT32: - { - grub_uint32_t *t32 = (grub_uint32_t *) target; - *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32) -diff -ruN grub-2.02/util/grub-module-verifier.c grub-2.02.aros/util/grub-module-verifier.c ---- grub-2.02/util/grub-module-verifier.c 2017-04-24 10:16:00.000000000 +0100 -+++ grub-2.02.aros/util/grub-module-verifier.c 2017-04-24 12:30:25.000000000 +0100 -@@ -19,6 +19,7 @@ - -1 - }, (int[]){ - R_X86_64_PC32, -+ R_X86_64_PLT32, - -1 - } - }, diff --git a/arch/all-pc/boot/grub2-host/mmakefile.src b/arch/all-pc/boot/grub2-host/mmakefile.src index 702555b779..041234b0cf 100644 --- a/arch/all-pc/boot/grub2-host/mmakefile.src +++ b/arch/all-pc/boot/grub2-host/mmakefile.src @@ -18,43 +18,37 @@ GRUBSRCDIR := $(PORTSDIR)/grub/grub-$(GRUB2_VERSION) $(BOOT_GRUB): %mkdirs_q $@ -$(BOOT_GRUB)/fonts: - %mkdirs_q $@ - $(BOOT_GRUB)/i386-pc: %mkdirs_q $@ $(BOOT_EFI): %mkdirs_q $@ -$(BOOT_EFI)/fonts: - %mkdirs_q $@ - $(BOOT_EFI)/i386-efi: %mkdirs_q $@ #MM -bootloader-grub2gfx-common: $(BOOT_GRUB)/splash.png $(BOOT_GRUB)/fonts/_unicode.pf2 $(BOOT_EFI)/splash.png $(BOOT_EFI)/fonts/_unicode.pf2 +bootloader-grub2gfx-common: $(BOOT_GRUB)/splash.png $(BOOT_GRUB)/_unicode.pf2 $(BOOT_EFI)/splash.png $(BOOT_EFI)/_unicode.pf2 $(BOOT_GRUB)/splash.png: splash.png $(BOOT_GRUB) $(CP) $< $(BOOT_GRUB) -$(BOOT_GRUB)/fonts/_unicode.pf2: unicode.pf2 $(BOOT_GRUB)/fonts - $(CP) $< $(BOOT_GRUB)/fonts/_unicode.pf2 +$(BOOT_GRUB)/_unicode.pf2: unicode.pf2 $(BOOT_GRUB) + $(CP) $< $(BOOT_GRUB)/_unicode.pf2 $(BOOT_EFI)/splash.png: splash.png $(BOOT_EFI) $(CP) $< $(BOOT_EFI) -$(BOOT_EFI)/fonts/_unicode.pf2: unicode.pf2 $(BOOT_EFI)/fonts - $(CP) $< $(BOOT_EFI)/fonts/_unicode.pf2 +$(BOOT_EFI)/_unicode.pf2: unicode.pf2 $(BOOT_EFI) + $(CP) $< $(BOOT_EFI)/_unicode.pf2 #MM -bootloader-grub2gfx-common-livecd: $(BOOT_GRUB)/fonts/unicode.pf2 $(BOOT_EFI)/fonts/unicode.pf2 +bootloader-grub2gfx-common-livecd: $(BOOT_GRUB)/unicode.pf2 $(BOOT_EFI)/unicode.pf2 -$(BOOT_GRUB)/fonts/unicode.pf2: unicode.pf2 $(BOOT_GRUB)/fonts +$(BOOT_GRUB)/unicode.pf2: unicode.pf2 $(BOOT_GRUB) $(CP) $< $(BOOT_GRUB) -$(BOOT_EFI)/fonts/unicode.pf2: unicode.pf2 $(BOOT_EFI)/fonts +$(BOOT_EFI)/unicode.pf2: unicode.pf2 $(BOOT_EFI) $(CP) $< $(BOOT_EFI) # avoid the make.tmpl s_flag in order to disable stripping of binaries diff --git a/arch/all-pc/boot/grub2-tools/Install-grub2.c b/arch/all-pc/boot/grub2-tools/Install-grub2.c index dd6fc31410..75c6e1feb7 100644 --- a/arch/all-pc/boot/grub2-tools/Install-grub2.c +++ b/arch/all-pc/boot/grub2-tools/Install-grub2.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. + Copyright © 1995-2015, The AROS Development Team. All rights reserved. $Id$ */ /****************************************************************************** @@ -48,12 +48,12 @@ SEE ALSO Partition, SYS:System/Format - + INTERNALS ******************************************************************************/ -#define DEBUG 0 +#define DEBUG 1 #include #include @@ -69,43 +69,32 @@ #include #include +/* These define some offsets */ +#define ASM_FILE /* Omit grub_uint64_t reference */ +#define GRUB_MACHINE I386_PC - -/* Defines for grub2 data */ -/* boot.img pointers */ -#define GRUB_BOOT_MACHINE_BPB_START 0x03 -#define GRUB_BOOT_MACHINE_BPB_END 0x5a -#define GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC 0x01b8 /* Following grub2 grub-setup sources */ -#define GRUB_BOOT_MACHINE_PART_START 0x01be -#define GRUB_BOOT_MACHINE_PART_END 0x01fe -#define GRUB_BOOT_MACHINE_KERNEL_SECTOR 0x5c -#define GRUB_BOOT_MACHINE_BOOT_DRIVE 0x64 -#define GRUB_BOOT_MACHINE_DRIVE_CHECK 0x66 - -/* core.img pointers */ -#define GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE 0x18 +#include +#include /* BIOS drive flag */ -#define BIOS_HDISK_FLAG 0x80 +#define BIOS_HDISK_FLAG 0x80 -#define MBR_MAX_PARTITIONS 4 -#define MBRT_EXTENDED 0x05 -#define MBRT_EXTENDED2 0x0f +#define MBR_MAX_PARTITIONS 4 +#define MBRT_EXTENDED 0x05 +#define MBRT_EXTENDED2 0x0f #define BLCKLIST_ELEMENTS 14 struct Volume { - struct MsgPort *mp; - struct IOExtTD *iotd; - ULONG readcmd; - ULONG writecmd; - ULONG startblock; + struct PartitionHandle *root; /* Device root handle */ + struct PartitionHandle *part; /* The actual partition */ + ULONG startblock; /* Offset, for stage volume */ ULONG countblock; - CONST_STRPTR device; + CONST_STRPTR device; /* Informative, for error messages */ ULONG unitnum; - UWORD SizeBlock; + UWORD SizeBlock; /* In bytes */ UBYTE flags; - BYTE partnum; + LONG partnum; /* -1 for device root */ ULONG *blockbuffer; ULONG dos_id; }; @@ -121,15 +110,15 @@ struct BlockNode UWORD seg_adr; }; -const TEXT version[] = "$VER: Install-grub2-i386-pc 41.4 (15.9.2012)"; +const TEXT version[] = "$VER: Install-grub2 41.3 " ADATE; -CONST_STRPTR CORE_IMG_FILE_NAME = "i386-pc/core.img"; +static CONST_STRPTR CORE_IMG_FILE_NAME = "core.img"; +static CONST_STRPTR template ="DEVICE/A,UNIT/N/K/A,PARTITIONNUMBER=PN/K/N,GRUB/K/A,FORCELBA/S,TEST/S"; -STRPTR template = - (STRPTR) ("DEVICE/A," "UNIT/N/K/A," "PARTITIONNUMBER=PN/K/N," "GRUB/K/A," - "FORCELBA/S"); +struct PartitionBase *PartitionBase; +IPTR myargs[7] = { 0, 0, 0, 0, 0, 0, 0 }; -IPTR myargs[7] = { 0, 0, 0, 0, 0, 0 }; +#define ARG_TESTING 5 struct FileSysStartupMsg *getDiskFSSM(CONST_STRPTR path) { @@ -141,157 +130,103 @@ struct FileSysStartupMsg *getDiskFSSM(CONST_STRPTR path) D(bug("[install] getDiskFSSM('%s')\n", path)); for (i = 0; (path[i]) && (path[i] != ':'); i++) - dname[i] = path[i]; + dname[i] = path[i]; if (path[i] == ':') { - dname[i] = 0; - dl = LockDosList(LDF_READ); - if (dl) - { - dn = (struct DeviceNode *) FindDosEntry(dl, dname, LDF_DEVICES); - UnLockDosList(LDF_READ); - if (dn) - { + dname[i] = 0; + dl = LockDosList(LDF_READ); + if (dl) + { + dn = (struct DeviceNode *) FindDosEntry(dl, dname, LDF_DEVICES); + UnLockDosList(LDF_READ); + if (dn) + { dname[i] = ':'; dname[i + 1] = '\0'; - if (IsFileSystem(dname)) - { - return (struct FileSysStartupMsg *) BADDR(dn->dn_Startup); - } - else - Printf("device '%s' doesn't contain a file system\n", - dname); - } - else - PrintFault(ERROR_OBJECT_NOT_FOUND, dname); - } + if (IsFileSystem(dname)) + { + return (struct FileSysStartupMsg *) BADDR(dn->dn_Startup); + } + else + Printf("device '%s' doesn't contain a file system\n", + dname); + } + else + PrintFault(ERROR_OBJECT_NOT_FOUND, dname); + } } else - Printf("'%s' doesn't contain a device name\n", path); + Printf("'%s' doesn't contain a device name\n", path); return 0; } -void fillGeometry(struct Volume *volume, struct DosEnvec *de) +static BOOL AllocBuffer(struct Volume *volume) +{ + volume->blockbuffer = AllocMem(volume->SizeBlock, MEMF_PUBLIC | MEMF_CLEAR); + if (!volume->blockbuffer) + { + Printf("Failed to allocate data buffer!\n"); + return FALSE; + } + return TRUE; +} + +BOOL fillGeometry(struct Volume *volume, struct DosEnvec *de) { ULONG spc; D(bug("[install] fillGeometry(%x)\n", volume)); spc = de->de_Surfaces * de->de_BlocksPerTrack; - volume->SizeBlock = de->de_SizeBlock; + volume->SizeBlock = de->de_SizeBlock << 2; volume->startblock = de->de_LowCyl * spc; volume->countblock = ((de->de_HighCyl - de->de_LowCyl + 1) * spc) - 1 + de->de_Reserved; + volume->part = volume->root; + return AllocBuffer(volume); } -void nsdCheck(struct Volume *volume) +void DumpVolume(struct Volume *volume, const char *header) { - struct NSDeviceQueryResult nsdq; - UWORD *cmdcheck; - - D(bug("[install] nsdCheck(%x)\n", volume)); + if (!myargs[ARG_TESTING]) + return; - if (((volume->startblock + volume->countblock) * /* last block */ - ((volume->SizeBlock << 2) / 512) /* 1 portion (block) equals 512 (bytes) */ - ) > 8388608) - { - nsdq.SizeAvailable = 0; - nsdq.DevQueryFormat = 0; - volume->iotd->iotd_Req.io_Command = NSCMD_DEVICEQUERY; - volume->iotd->iotd_Req.io_Data = &nsdq; - volume->iotd->iotd_Req.io_Length = sizeof(struct NSDeviceQueryResult); - if (DoIO((struct IORequest *) &volume->iotd->iotd_Req) == IOERR_NOCMD) - { - Printf("Device doesn't understand NSD-Query\n"); - } - else - { - if ((volume->iotd->iotd_Req.io_Actual > - sizeof(struct NSDeviceQueryResult)) - || (volume->iotd->iotd_Req.io_Actual == 0) - || (volume->iotd->iotd_Req.io_Actual != nsdq.SizeAvailable)) - { - Printf("WARNING wrong io_Actual using NSD\n"); - } - else - { - if (nsdq.DeviceType != NSDEVTYPE_TRACKDISK) - Printf("WARNING no trackdisk type\n"); - for (cmdcheck = nsdq.SupportedCommands; *cmdcheck; cmdcheck++) - { - if (*cmdcheck == NSCMD_TD_READ64) - volume->readcmd = NSCMD_TD_READ64; - if (*cmdcheck == NSCMD_TD_WRITE64); - volume->writecmd = NSCMD_TD_WRITE64; - } - if ((volume->readcmd != NSCMD_TD_READ64) || - (volume->writecmd != NSCMD_TD_WRITE64)) - Printf("WARNING no READ64/WRITE64\n"); - } - } - } + Printf("%s: %s unit %lu partition %ld\n", header, volume->device, volume->unitnum, volume->partnum); } -struct Volume *initVolume(CONST_STRPTR device, ULONG unit, ULONG flags, - struct DosEnvec *de) +struct Volume *initVolume(CONST_STRPTR device, ULONG unit) { struct Volume *volume; - LONG error = 0; D(bug("[install] initVolume(%s:%d)\n", device, unit)); - volume = AllocVec(sizeof(struct Volume), MEMF_PUBLIC | MEMF_CLEAR); + volume = AllocMem(sizeof(struct Volume), MEMF_PUBLIC | MEMF_CLEAR); if (volume) { - volume->mp = CreateMsgPort(); - if (volume->mp) - { - volume->iotd = - (struct IOExtTD *) CreateIORequest(volume->mp, - sizeof(struct IOExtTD)); - if (volume->iotd) - { - volume->blockbuffer = - AllocVec(de->de_SizeBlock << 2, MEMF_PUBLIC | MEMF_CLEAR); - if (volume->blockbuffer) - { - if (OpenDevice - (device, - unit, (struct IORequest *) volume->iotd, flags) == 0) - { - if (strcmp((const char *) device, TD_NAME) == 0) - volume->flags |= VF_IS_TRACKDISK; - else - volume->flags |= VF_IS_RDB; /* just assume we have RDB */ - volume->readcmd = CMD_READ; - volume->writecmd = CMD_WRITE; - volume->device = device; - volume->unitnum = unit; - volume->dos_id = 0; - fillGeometry(volume, de); - nsdCheck(volume); - return volume; - } - else - error = ERROR_NO_FREE_STORE; - FreeVec(volume->blockbuffer); - } - else - error = ERROR_NO_FREE_STORE; - DeleteIORequest((struct IORequest *) volume->iotd); - } - else - error = ERROR_NO_FREE_STORE; - DeleteMsgPort(volume->mp); - } - else - error = ERROR_NO_FREE_STORE; - FreeVec(volume); + volume->root = OpenRootPartition(device, unit); + if (volume->root) + { + if (strcmp((const char *) device, TD_NAME) == 0) + volume->flags |= VF_IS_TRACKDISK; + else + volume->flags |= VF_IS_RDB; /* just assume we have RDB */ + + volume->device = device; + volume->unitnum = unit; + volume->startblock = 0; + volume->partnum = -1; + volume->dos_id = 0; + + return volume; + } + else + Printf("Failed to open device %s unit %ld!\n", device, unit); + + FreeMem(volume, sizeof(struct Volume)); } else - error = ERROR_NO_FREE_STORE; + PrintFault(ERROR_NO_FREE_STORE, NULL); - PrintFault(error, NULL); return NULL; } @@ -299,50 +234,33 @@ void uninitVolume(struct Volume *volume) { D(bug("[install] uninitVolume(%x)\n", volume)); - CloseDevice((struct IORequest *) volume->iotd); - FreeVec(volume->blockbuffer); - DeleteIORequest((struct IORequest *) volume->iotd); - DeleteMsgPort(volume->mp); - FreeVec(volume); -} - -static ULONG _readwriteBlock(struct Volume *volume, - ULONG block, APTR buffer, ULONG length, - ULONG command) -{ - UQUAD offset; - ULONG retval = 0; - - volume->iotd->iotd_Req.io_Command = command; - volume->iotd->iotd_Req.io_Length = length; - volume->iotd->iotd_Req.io_Data = buffer; - offset = (UQUAD) (volume->startblock + block) * (volume->SizeBlock << 2); - volume->iotd->iotd_Req.io_Offset = offset & 0xFFFFFFFF; - volume->iotd->iotd_Req.io_Actual = offset >> 32; - retval = DoIO((struct IORequest *) &volume->iotd->iotd_Req); - if (volume->flags & VF_IS_TRACKDISK) + if (volume->blockbuffer) + FreeMem(volume->blockbuffer, volume->SizeBlock); + if (volume->root) { - volume->iotd->iotd_Req.io_Command = TD_MOTOR; - volume->iotd->iotd_Req.io_Length = 0; - DoIO((struct IORequest *) &volume->iotd->iotd_Req); + ClosePartitionTable(volume->root); + CloseRootPartition(volume->root); } - return retval; + FreeMem(volume, sizeof (struct Volume)); } ULONG readBlock(struct Volume * volume, ULONG block, APTR buffer, ULONG size) { D(bug("[install] readBlock(vol:%x, block:%d, %d bytes)\n", - volume, block, size)); + volume, block, size)); - return _readwriteBlock(volume, block, buffer, size, volume->readcmd); + return ReadPartitionData(volume->startblock + block, volume->part, buffer, size); } ULONG writeBlock(struct Volume * volume, ULONG block, APTR buffer, ULONG size) { D(bug("[install] writeBlock(vol:%x, block:%d, %d bytes)\n", - volume, block, size)); + volume, block, size)); + + if (myargs[ARG_TESTING]) + return 0; - return _readwriteBlock(volume, block, buffer, size, volume->writecmd); + return WritePartitionData(volume->startblock + block, volume->part, buffer, size); } static BOOL isKnownFs(ULONG dos_id) @@ -356,350 +274,266 @@ static BOOL isKnownFs(ULONG dos_id) case ID_FASTDIR_FFS_DISK: case ID_SFS_BE_DISK: case ID_SFS_LE_DISK: - return TRUE; + return TRUE; } return FALSE; } -BOOL isvalidFileSystem(struct Volume * volume, CONST_STRPTR device, - ULONG unit) +static BOOL GetPartitionNum(struct Volume *volume, struct PartitionHandle *parent, + struct PartitionHandle **extph) +{ + struct PartitionHandle *pn; + UQUAD offset, start, end; + + GetPartitionAttrsTags(parent, PT_STARTBLOCK, &offset, TAG_DONE); + + for (pn = (struct PartitionHandle *) parent->table->list.lh_Head; + pn->ln.ln_Succ; + pn = (struct PartitionHandle *) pn->ln.ln_Succ) + { + if (extph) + { + struct PartitionType ptype = { }; + + GetPartitionAttrsTags(pn, PT_TYPE, &ptype, TAG_DONE); + if (ptype.id[0] == MBRT_EXTENDED || ptype.id[0] == MBRT_EXTENDED2) + { + *extph = pn; + continue; + } + } + + GetPartitionAttrsTags(pn, PT_STARTBLOCK, &start, PT_ENDBLOCK, &end, TAG_DONE); + start += offset; + end += offset; + + D(KPrintF("[install] checking partition start %llu end %llu\n", start, end)); + if ((volume->startblock >= start) && (volume->startblock <= end)) + { + GetPartitionAttrsTags(pn, PT_POSITION, &volume->partnum, TAG_DONE); + return TRUE; + } + } + return FALSE; +} + +BOOL isvalidFileSystem(struct Volume *volume) { BOOL retval = FALSE; - struct PartitionBase *PartitionBase; - struct PartitionHandle *ph; ULONG dos_id; - D(bug("[install] isvalidFileSystem(%x, %s, %d)\n", volume, device, unit)); + D(bug("[install] isvalidFileSystem(%s, %d)\n", volume->device, volume->unitnum)); - if (readBlock(volume, 0, volume->blockbuffer, 512)) + if (readBlock(volume, 0, volume->blockbuffer, volume->SizeBlock)) { - Printf("Read Error\n"); - return FALSE; + Printf("Read Error\n"); + return FALSE; } dos_id = AROS_BE2LONG(volume->blockbuffer[0]); if (!isKnownFs(dos_id)) { - /* first block has no DOS\x so we don't have RDB for sure */ - volume->flags &= ~VF_IS_RDB; - if (readBlock(volume, 1, volume->blockbuffer, 512)) - { - Printf("Read Error\n"); - return FALSE; - } - - dos_id = AROS_BE2LONG(volume->blockbuffer[0]); - - if (!isKnownFs(dos_id)) - return FALSE; - else - volume->dos_id = dos_id; - } - else - volume->dos_id = dos_id; + /* first block has no DOS\x so we don't have RDB for sure */ + volume->flags &= ~VF_IS_RDB; + if (readBlock(volume, 1, volume->blockbuffer, volume->SizeBlock)) + { + Printf("Read Error\n"); + return FALSE; + } + + dos_id = AROS_BE2LONG(volume->blockbuffer[0]); - volume->partnum = -1; + if (!isKnownFs(dos_id)) + return FALSE; + } + D(bug("[install] Detected known DOSType 0x%08X\n", dos_id)); + volume->dos_id = dos_id; - PartitionBase = - (struct PartitionBase *) OpenLibrary((CONST_STRPTR) - "partition.library", 1); - if (PartitionBase) + D(bug("[install] Looking for partition startblock %lu\n", volume->startblock)); + if (OpenPartitionTable(volume->root) == 0) { - ph = OpenRootPartition(device, unit); - if (ph) - { - if (OpenPartitionTable(ph) == 0) - { - struct TagItem tags[3]; - IPTR type; - - tags[1].ti_Tag = TAG_DONE; - tags[0].ti_Tag = PTT_TYPE; - tags[0].ti_Data = (STACKIPTR) & type; - GetPartitionTableAttrs(ph, tags); - if (type == PHPTT_MBR) - { - struct PartitionHandle *pn; - struct DosEnvec de; - struct PartitionHandle *extph = NULL; - struct PartitionType ptype = { }; - - tags[0].ti_Tag = PT_DOSENVEC; - tags[0].ti_Data = (STACKIPTR) & de; - tags[1].ti_Tag = PT_TYPE; - tags[1].ti_Data = (STACKIPTR) & ptype; - tags[2].ti_Tag = TAG_DONE; - pn = (struct PartitionHandle *) ph->table->list.lh_Head; - while (pn->ln.ln_Succ) - { - ULONG scp; - - GetPartitionAttrs(pn, tags); - if (ptype.id[0] == MBRT_EXTENDED - || ptype.id[0] == MBRT_EXTENDED2) - extph = pn; - else - { - scp = de.de_Surfaces * de.de_BlocksPerTrack; - if ((volume->startblock >= (de.de_LowCyl * scp)) - && (volume->startblock <= - (((de.de_HighCyl + 1) * scp) - 1))) - break; - } - pn = (struct PartitionHandle *) pn->ln.ln_Succ; - } - if (pn->ln.ln_Succ) - { - tags[0].ti_Tag = PT_POSITION; - tags[0].ti_Data = (STACKIPTR) & type; - tags[1].ti_Tag = TAG_DONE; - GetPartitionAttrs(pn, tags); - volume->partnum = (UBYTE) type; - retval = TRUE; - D(bug - ("[install] Primary partition found: partnum=%d\n", - volume->partnum)); - } - else if (extph != NULL) - { - if (OpenPartitionTable(extph) == 0) - { - tags[0].ti_Tag = PTT_TYPE; - tags[0].ti_Data = (STACKIPTR) & type; - tags[1].ti_Tag = TAG_DONE; - GetPartitionTableAttrs(extph, tags); - if (type == PHPTT_EBR) - { - tags[0].ti_Tag = PT_DOSENVEC; - tags[0].ti_Data = (STACKIPTR) & de; - tags[1].ti_Tag = TAG_DONE; - pn = (struct PartitionHandle *) extph->table-> - list.lh_Head; - while (pn->ln.ln_Succ) - { - ULONG offset, scp; - - offset = extph->de.de_LowCyl - * extph->de.de_Surfaces - * extph->de.de_BlocksPerTrack; - GetPartitionAttrs(pn, tags); - scp = - de.de_Surfaces * de.de_BlocksPerTrack; - if ((volume->startblock >= - offset + (de.de_LowCyl * scp)) - && (volume->startblock <= - offset + - (((de.de_HighCyl + 1) * scp) - - 1))) - break; - pn = (struct PartitionHandle *) pn->ln. - ln_Succ; - } - if (pn->ln.ln_Succ) - { - tags[0].ti_Tag = PT_POSITION; - tags[0].ti_Data = (STACKIPTR) & type; - GetPartitionAttrs(pn, tags); - volume->partnum = - MBR_MAX_PARTITIONS + (UBYTE) type; - retval = TRUE; - D(bug - ("[install] Logical partition found: partnum=%d\n", - (int) volume->partnum)); - } - } - ClosePartitionTable(extph); - } - } - } - else - { - if (type == PHPTT_RDB) - { - /* just use whole hard disk */ - retval = TRUE; - } - else - Printf - ("only MBR and RDB partition tables are supported\n"); - } - ClosePartitionTable(ph); - } - else - { - /* just use whole hard disk */ - retval = TRUE; - } - CloseRootPartition(ph); - } - else - Printf("Error OpenRootPartition(%s,%lu)\n", device, (long)unit); - CloseLibrary((struct Library *) PartitionBase); + struct TagItem tags[2]; + ULONG type; + + tags[1].ti_Tag = TAG_DONE; + tags[0].ti_Tag = PTT_TYPE; + tags[0].ti_Data = (STACKIPTR) & type; + GetPartitionTableAttrs(volume->root, tags); + + if (type == PHPTT_MBR) + { + struct PartitionHandle *extph = NULL; + + D(bug("[install] Found MBR table\n")); + if (GetPartitionNum(volume, volume->root, &extph)) + { + retval = TRUE; + D(bug("[install] Primary partition found: partnum=%d\n", volume->partnum)); + } + else if (extph != NULL) + { + if (OpenPartitionTable(extph) == 0) + { + GetPartitionTableAttrs(extph, tags); + if (type == PHPTT_EBR) + { + D(bug("[install] Found EBR table\n")); + if (GetPartitionNum(volume, extph, NULL)) + { + volume->partnum += MBR_MAX_PARTITIONS; + retval = TRUE; + D(bug("[install] Logical partition found: partnum=%d\n", volume->partnum)); + } + } + ClosePartitionTable(extph); + } + } + } + else if (type == PHPTT_RDB) + { + /* just use whole hard disk */ + retval = TRUE; + } + else + Printf("only MBR and RDB partition tables are supported\n"); + + ClosePartitionTable(volume->root); } else - Printf("Couldn't open partition.library\n"); + { + /* just use whole hard disk */ + retval = TRUE; + } return retval; } struct Volume *getGrubStageVolume(CONST_STRPTR device, ULONG unit, - ULONG flags, struct DosEnvec *de) + ULONG flags, struct DosEnvec *de) { struct Volume *volume; - volume = initVolume(device, unit, flags, de); + volume = initVolume(device, unit); D(bug("[install] getGrubStageVolume(): volume=%x\n", volume)); if (volume) { - if (isvalidFileSystem(volume, device, unit)) - return volume; - else - { - Printf("stage2 is on an unsupported file system\n"); - PrintFault(ERROR_OBJECT_WRONG_TYPE, NULL); - } - uninitVolume(volume); + if (fillGeometry(volume, de)) + { + if (isvalidFileSystem(volume)) + return volume; + else + { + Printf("stage2 is on an unsupported file system\n"); + PrintFault(ERROR_OBJECT_WRONG_TYPE, NULL); + } + } + uninitVolume(volume); } return 0; } -BOOL isvalidPartition(CONST_STRPTR device, ULONG unit, LONG * pnum, - struct DosEnvec * de) +BOOL isvalidPartition(struct Volume *volume, LONG *pnum) { - struct PartitionBase *PartitionBase; - struct PartitionHandle *ph; ULONG type; + struct TagItem tags[2]; BOOL retval = FALSE; - D(bug - ("[install] isvalidPartition(%s:%d, part:%d)\n", device, unit, pnum)); + D(bug("[install] isvalidPartition(%d)\n", pnum)); - PartitionBase = - (struct PartitionBase *) OpenLibrary((CONST_STRPTR) - "partition.library", 1); - if (PartitionBase) + tags[1].ti_Tag = TAG_DONE; + + if (pnum) { - ph = OpenRootPartition(device, unit); - if (ph) - { - struct TagItem tags[2]; - - tags[1].ti_Tag = TAG_DONE; - /* is there a partition table? */ - if (OpenPartitionTable(ph) == 0) - { - if (pnum) - { - /* install into partition bootblock */ - tags[0].ti_Tag = PTT_TYPE; - tags[0].ti_Data = (STACKIPTR) & type; - GetPartitionTableAttrs(ph, tags); - if (type == PHPTT_MBR) - { - struct PartitionHandle *pn; - - /* search for partition */ - tags[0].ti_Tag = PT_POSITION; - tags[0].ti_Data = (STACKIPTR) & type; - pn = (struct PartitionHandle *) ph->table->list. - lh_Head; - while (pn->ln.ln_Succ) - { - GetPartitionAttrs(pn, tags); - if (type == *pnum) - break; - pn = (struct PartitionHandle *) pn->ln.ln_Succ; - } - if (pn->ln.ln_Succ) - { - struct PartitionType ptype; - - /* is it an AROS partition? */ - tags[0].ti_Tag = PT_TYPE; - tags[0].ti_Data = (STACKIPTR) & ptype; - GetPartitionAttrs(pn, tags); - if (ptype.id[0] == 0x30) - { - tags[0].ti_Tag = PT_DOSENVEC; - tags[0].ti_Data = (STACKIPTR) de; - GetPartitionAttrs(pn, tags); - retval = TRUE; - } - else - Printf - ("partition is not of type AROS (0x30)\n"); - } - else - { - Printf - ("partition %ld not found on device %s unit %lu\n", - (long)*pnum, device, (long)unit); - } - } - else - Printf - ("you can only install in partitions which are MBR partitioned\n"); - } - else - { - /* install into MBR */ - tags[0].ti_Tag = PTT_TYPE; - tags[0].ti_Data = (STACKIPTR) & type; - GetPartitionTableAttrs(ph, tags); - if ((type == PHPTT_MBR) || (type == PHPTT_RDB)) - { - tags[0].ti_Tag = PT_DOSENVEC; - tags[0].ti_Data = (STACKIPTR) de; - GetPartitionAttrs(ph, tags); - retval = TRUE; - } - else - Printf - ("partition table type must be either MBR or RDB\n"); - } - ClosePartitionTable(ph); - } - else - { - /* FIXME: GetPartitionAttr() should always work for root partition */ - CopyMem(&ph->de, de, sizeof(struct DosEnvec)); - retval = TRUE; - } - CloseRootPartition(ph); - } - else - Printf("Error OpenRootPartition(%s,%lu)\n", device, (long)unit); - CloseLibrary((struct Library *) PartitionBase); + /* install into partition bootblock */ + /* is there a partition table? */ + if (OpenPartitionTable(volume->root) == 0) + { + tags[0].ti_Tag = PTT_TYPE; + tags[0].ti_Data = (STACKIPTR) & type; + GetPartitionTableAttrs(volume->root, tags); + if (type == PHPTT_MBR) + { + struct PartitionHandle *pn; + + /* search for partition */ + tags[0].ti_Tag = PT_POSITION; + tags[0].ti_Data = (STACKIPTR) & type; + pn = (struct PartitionHandle *) volume->root->table->list.lh_Head; + while (pn->ln.ln_Succ) + { + GetPartitionAttrs(pn, tags); + if (type == *pnum) + break; + pn = (struct PartitionHandle *) pn->ln.ln_Succ; + } + if (pn->ln.ln_Succ) + { + struct PartitionType ptype; + + /* is it an AROS partition? */ + tags[0].ti_Tag = PT_TYPE; + tags[0].ti_Data = (STACKIPTR) & ptype; + GetPartitionAttrs(pn, tags); + if (ptype.id[0] == 0x30) + { + volume->part = pn; + retval = TRUE; + } + else + Printf("partition is not of type AROS (0x30)\n"); + } + else + Printf("partition %ld not found on device %s unit %lu\n", *pnum, volume->device, volume->unitnum); + } + else + Printf("you can only install in partitions which are MBR partitioned\n"); + } + else + Printf("Failed to open partition table on device %s unit %lu\n", *pnum, volume->device, volume->unitnum); } else - Printf("Couldn't open partition.library\n"); + { + /* install into MBR */ + volume->part = volume->root; + retval = TRUE; + } + + if (retval) + { + volume->SizeBlock = volume->part->de.de_SizeBlock << 2; + retval = AllocBuffer(volume); + } + return retval; } struct Volume *getBBVolume(CONST_STRPTR device, ULONG unit, LONG * partnum) { struct Volume *volume; - struct DosEnvec de; D(bug("[install] getBBVolume(%s:%d, %d)\n", device, unit, partnum)); - if (isvalidPartition(device, unit, partnum, &de)) + volume = initVolume(device, unit); + if (!volume) + return NULL; + + if (isvalidPartition(volume, partnum)) { - volume = initVolume(device, unit, 0, &de); - volume->partnum = partnum ? *partnum : -1; - readBlock(volume, 0, volume->blockbuffer, 512); - if (AROS_BE2LONG(volume->blockbuffer[0]) != IDNAME_RIGIDDISK) - { - /* Clear the boot sector region! */ - memset(volume->blockbuffer, 0x00, 446); - return volume; - } - else - Printf("no space for bootblock (RDB is on block 0)\n"); + volume->partnum = partnum ? *partnum : -1; + readBlock(volume, 0, volume->blockbuffer, volume->SizeBlock); + if (AROS_BE2LONG(volume->blockbuffer[0]) != IDNAME_RIGIDDISK) + { + /* Clear the boot sector region! */ + memset(volume->blockbuffer, 0x00, 446); + return volume; + } + else + Printf("no space for bootblock (RDB is on block 0)\n"); } + uninitVolume(volume); return NULL; } @@ -735,76 +569,76 @@ BOOL writeBootIMG(STRPTR bootimgpath, struct Volume * bootimgvol, struct Volume fh = Open(bootimgpath, MODE_OLDFILE); if (fh) { - if (Read(fh, bootimgvol->blockbuffer, 512) == 512) - { - /* install into MBR ? */ - if ((bootimgvol->startblock == 0) - && (!(bootimgvol->flags & VF_IS_TRACKDISK))) - { - APTR boot_img = bootimgvol->blockbuffer; - - UBYTE *boot_drive = + if (Read(fh, bootimgvol->blockbuffer, 512) == 512) + { + /* install into MBR ? */ + if ((bootimgvol->startblock == 0) + && (!(bootimgvol->flags & VF_IS_TRACKDISK))) + { + APTR boot_img = bootimgvol->blockbuffer; + + UBYTE *boot_drive = (UBYTE *) (boot_img + GRUB_BOOT_MACHINE_BOOT_DRIVE); - UWORD *boot_drive_check = - (UWORD *) (boot_img + GRUB_BOOT_MACHINE_DRIVE_CHECK); + UWORD *boot_drive_check = + (UWORD *) (boot_img + GRUB_BOOT_MACHINE_DRIVE_CHECK); if (unit == bootimgvol->unitnum) *boot_drive = 0xFF; else *boot_drive = getDriveNumber(coreimgvol->device, unit) | BIOS_HDISK_FLAG; - *boot_drive_check = 0x9090; - - D(bug("[install] writeBootIMG: Install to HARDDISK\n")); - - /* read old MBR */ - error = readBlock(bootimgvol, 0, coreimgvol->blockbuffer, 512); - - D(bug("[install] writeBootIMG: MBR Buffer @ %x\n", bootimgvol->blockbuffer)); - D(bug("[install] writeBootIMG: Copying MBR BPB to %x\n", - (char *) bootimgvol->blockbuffer + GRUB_BOOT_MACHINE_BPB_START)); - /* copy BPB (BIOS Parameter Block) */ - CopyMem - ((APTR) ((char *) coreimgvol->blockbuffer + GRUB_BOOT_MACHINE_BPB_START), - (APTR) ((char *) bootimgvol->blockbuffer + GRUB_BOOT_MACHINE_BPB_START), - (GRUB_BOOT_MACHINE_BPB_END - GRUB_BOOT_MACHINE_BPB_START)); - - /* copy partition table - [Overwrites Floppy boot code] */ - D(bug("[install] writeBootIMG: Copying MBR Partitions to %x\n", - (char *) bootimgvol->blockbuffer + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC)); - CopyMem((APTR) ((char *) coreimgvol->blockbuffer + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC), - (APTR) ((char *) bootimgvol->blockbuffer + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC), - (GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC)); - - /* Store the core.img pointer .. */ - ULONG * coreimg_sector_start = (ULONG *) (boot_img - + GRUB_BOOT_MACHINE_KERNEL_SECTOR); - coreimg_sector_start[0] = block; - D(bug("[install] writeBootIMG: core.img pointer = %ld\n", block)); - } - else - { - D(bug("[install] writeBootIMG: Install to FLOPPY\n")); - } - - if (error == 0) - { - error = writeBlock(bootimgvol, 0, bootimgvol->blockbuffer, 512); + *boot_drive_check = 0x9090; + + D(bug("[install] writeBootIMG: Install to HARDDISK\n")); + + /* read old MBR */ + error = readBlock(bootimgvol, 0, coreimgvol->blockbuffer, 512); + + D(bug("[install] writeBootIMG: MBR Buffer @ %x\n", bootimgvol->blockbuffer)); + D(bug("[install] writeBootIMG: Copying MBR BPB to %x\n", + (char *) bootimgvol->blockbuffer + GRUB_BOOT_MACHINE_BPB_START)); + /* copy BPB (BIOS Parameter Block) */ + CopyMem + ((APTR) ((char *) coreimgvol->blockbuffer + GRUB_BOOT_MACHINE_BPB_START), + (APTR) ((char *) bootimgvol->blockbuffer + GRUB_BOOT_MACHINE_BPB_START), + (GRUB_BOOT_MACHINE_BPB_END - GRUB_BOOT_MACHINE_BPB_START)); + + /* copy partition table - [Overwrites Floppy boot code] */ + D(bug("[install] writeBootIMG: Copying MBR Partitions to %x\n", + (char *) bootimgvol->blockbuffer + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC)); + CopyMem((APTR) ((char *) coreimgvol->blockbuffer + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC), + (APTR) ((char *) bootimgvol->blockbuffer + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC), + (GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC)); + + /* Store the core.img pointer .. */ + ULONG * coreimg_sector_start = (ULONG *) (boot_img + + GRUB_BOOT_MACHINE_KERNEL_SECTOR); + coreimg_sector_start[0] = block; + D(bug("[install] writeBootIMG: core.img pointer = %ld\n", block)); + } + else + { + D(bug("[install] writeBootIMG: Install to FLOPPY\n")); + } + + if (error == 0) + { + error = writeBlock(bootimgvol, 0, bootimgvol->blockbuffer, 512); - if (error) - Printf("WriteError %lu\n", (long)error); - else - retval = TRUE; - } - else - Printf("WriteError %lu\n", (long)error); - } - else - Printf("%s: Read Error\n", bootimgpath); - Close(fh); + if (error) + Printf("WriteError %lu\n", (long)error); + else + retval = TRUE; + } + else + Printf("WriteError %lu\n", (long)error); + } + else + Printf("%s: Read Error\n", bootimgpath); + Close(fh); } else - PrintFault(IoErr(), bootimgpath); + PrintFault(IoErr(), bootimgpath); return retval; } @@ -822,103 +656,101 @@ ULONG collectBlockListFFS(struct Volume *volume, ULONG block, struct BlockNode * /* Clear the core.img sector pointers region! */ memset((UBYTE*)&blocklist[-BLCKLIST_ELEMENTS],0x00, BLCKLIST_ELEMENTS*sizeof(struct BlockNode)); - /* - The number of first block of core.img will be stored in boot.img - so skip the first filekey in the first loop - */ + /* + The number of first block of core.img will be stored in boot.img + so skip the first filekey in the first loop + */ - retval = _readwriteBlock(volume, block, volume->blockbuffer, volume->SizeBlock<<2, - volume->readcmd); + retval = readBlock(volume, block, volume->blockbuffer, volume->SizeBlock); if (retval) { D(bug("[install] collectBlockListFFS: ERROR reading block (error: %ld\n", retval)); - Printf("ReadError %lu\n", (long)retval); - return 0; - } - - i = volume->SizeBlock - 52; - first_block = AROS_BE2LONG(volume->blockbuffer[volume->SizeBlock-51]); - blk_count=0; - + Printf("ReadError %lu\n", (long)retval); + return 0; + } + + i = volume->SizeBlock - 52; + first_block = AROS_BE2LONG(volume->blockbuffer[volume->SizeBlock-51]); + blk_count=0; + D(bug("[install] collectBlockListFFS: First block @ %ld, i:%d\n", first_block, i)); - - do - { - retval = _readwriteBlock(volume, block, volume->blockbuffer, volume->SizeBlock<<2, - volume->readcmd); - if (retval) - { + + do + { + retval = readBlock(volume, block, volume->blockbuffer, volume->SizeBlock); + if (retval) + { D(bug("[install] collectBlockListFFS: ERROR reading block (error: %ld)\n", retval)); - Printf("ReadError %lu\n", (long)retval); - return 0; - } + Printf("ReadError %lu\n", (long)retval); + return 0; + } D(bug("[install] collectBlockListFFS: read block %ld, i = %d\n", block, i)); - while ((i>=6) && (volume->blockbuffer[i])) - { + while ((i>=6) && (volume->blockbuffer[i])) + { D(bug("[install] collectBlockListFFS: i = %d\n", i)); - /* - if current sector follows right after last sector - then we don't need a new element - */ - if ((blocklist[blk_count].sector_lo) && - ((blocklist[blk_count].sector_lo+blocklist[blk_count].count)== - AROS_BE2LONG(volume->blockbuffer[i]))) - { - blocklist[blk_count].count += 1; + /* + if current sector follows right after last sector + then we don't need a new element + */ + if ((blocklist[blk_count].sector_lo) && + ((blocklist[blk_count].sector_lo+blocklist[blk_count].count)== + AROS_BE2LONG(volume->blockbuffer[i]))) + { + blocklist[blk_count].count += 1; D(bug("[install] collectBlockListFFS: sector %d follows previous - increasing count of block %d to %d\n", i, blk_count, blocklist[blk_count].count)); - } - else - { - blk_count--; /* decrement first */ + } + else + { + blk_count--; /* decrement first */ D(bug("[install] collectBlockListFFS: store new block (%d)\n", blk_count)); - if ((blk_count-1) <= -BLCKLIST_ELEMENTS) - { + if ((blk_count-1) <= -BLCKLIST_ELEMENTS) + { D(bug("[install] collectBlockListFFS: ERROR: out of block space at sector %d, block %d\n", i, blk_count)); - Printf("There is no more space to save blocklist in core.img\n"); - return 0; - } + Printf("There is no more space to save blocklist in core.img\n"); + return 0; + } D(bug("[install] collectBlockListFFS: storing sector pointer for %d in block %d\n", i, blk_count)); - blocklist[blk_count].sector_lo = AROS_BE2LONG(volume->blockbuffer[i]); - blocklist[blk_count].sector_hi = 0; - blocklist[blk_count].count = 1; - } - i--; - } - i = volume->SizeBlock - 51; - block = AROS_BE2LONG(volume->blockbuffer[volume->SizeBlock - 2]); + blocklist[blk_count].sector_lo = AROS_BE2LONG(volume->blockbuffer[i]); + blocklist[blk_count].sector_hi = 0; + blocklist[blk_count].count = 1; + } + i--; + } + i = volume->SizeBlock - 51; + block = AROS_BE2LONG(volume->blockbuffer[volume->SizeBlock - 2]); D(bug("[install] collectBlockListFFS: next block %d, i = %d\n", block, i)); - } while (block); + } while (block); - /* - blocks in blocklist are relative to the first - sector of the HD (not partition) - */ + /* + blocks in blocklist are relative to the first + sector of the HD (not partition) + */ D(bug("[install] collectBlockListFFS: successfully updated pointers for %d blocks\n", blk_count)); - i = 0; - for (count=-1;count>=blk_count;count--) - { - blocklist[count].sector_lo += volume->startblock; - blocklist[count].seg_adr = 0x820 + (i*32); - i += blocklist[count].count; + i = 0; + for (count=-1;count>=blk_count;count--) + { + blocklist[count].sector_lo += volume->startblock; + blocklist[count].seg_adr = 0x820 + (i*32); + i += blocklist[count].count; D(bug("[install] collectBlockListFFS: correcting block %d for partition start\n", count)); D(bug("[install] collectBlockListFFS: sector : %ld seg_adr : %x\n", blocklist[count].sector_lo, blocklist[count].seg_adr)); - } + } first_block += volume->startblock; D(bug("[install] collectBlockListFFS: corrected first block for partition start: %ld\n", first_block)); - return first_block; + return first_block; } /* Collects the list of blocks that a file occupies on SFS filesystem */ @@ -952,15 +784,14 @@ ULONG collectBlockListSFS(struct Volume *volume, ULONG objectnode, struct BlockN */ /* Read root block */ - retval = _readwriteBlock(volume, 0, volume->blockbuffer, volume->SizeBlock<<2, - volume->readcmd); + retval = readBlock(volume, 0, volume->blockbuffer, volume->SizeBlock); if (retval) { D(bug("[install] collectBlockListSFS: ERROR reading root block (error: %ld)\n", retval)); - Printf("ReadError %lu\n", (long)retval); - return 0; - } + Printf("ReadError %lu\n", (long)retval); + return 0; + } /* Get block pointers from root block */ block_objectnoderoot = AROS_BE2LONG(volume->blockbuffer[28]); /* objectnoderoot - 29th ULONG */ @@ -978,8 +809,7 @@ ULONG collectBlockListSFS(struct Volume *volume, ULONG objectnode, struct BlockN nextblock, objectnode)); while(1) { - _readwriteBlock(volume, nextblock, volume->blockbuffer, volume->SizeBlock<<2, - volume->readcmd); + readBlock(volume, nextblock, volume->blockbuffer, volume->SizeBlock); /* If nodes == 1, we are at the correct nodecontainer, else go to next nodecontainer */ if (AROS_BE2LONG(volume->blockbuffer[4]) == 1) @@ -1004,8 +834,8 @@ ULONG collectBlockListSFS(struct Volume *volume, ULONG objectnode, struct BlockN if (block_sfsobjectcontainer == 0) { D(bug("[install] collectBlockListSFS: SFSObjectContainer not found\n")); - Printf("SFSObjectContainer not found\n"); - return 0; + Printf("SFSObjectContainer not found\n"); + return 0; } @@ -1015,15 +845,14 @@ ULONG collectBlockListSFS(struct Volume *volume, ULONG objectnode, struct BlockN while((block_sfsobjectcontainer != 0) && (first_block == 0)) { /* Read next SFS container block */ - retval = _readwriteBlock(volume, block_sfsobjectcontainer, volume->blockbuffer, volume->SizeBlock<<2, - volume->readcmd); + retval = readBlock(volume, block_sfsobjectcontainer, volume->blockbuffer, volume->SizeBlock); if (retval) { D(bug("[install] collectBlockListSFS: ERROR reading block (error: %ld)\n", retval)); - Printf("ReadError %lu\n", (long)retval); - return 0; - } + Printf("ReadError %lu\n", (long)retval); + return 0; + } /* Iterate over SFS objects and match the objectnode */ /* @@ -1049,9 +878,9 @@ ULONG collectBlockListSFS(struct Volume *volume, ULONG objectnode, struct BlockN /* Find end of name and end of comment */ tmpBytePtr += 25; /* Point to name */ count = 0; - for (i = 2; i > 0; tmpBytePtr++, count++) - if (*tmpBytePtr == '\0') - i--; + for (i = 2; i > 0; tmpBytePtr++, count++) + if (*tmpBytePtr == '\0') + i--; /* Correction for aligment */ if ((count & 0x01) == 0 ) @@ -1066,8 +895,8 @@ ULONG collectBlockListSFS(struct Volume *volume, ULONG objectnode, struct BlockN if (first_block == 0) { D(bug("[install] collectBlockListSFS: First block not found\n")); - Printf("First block not found\n"); - return 0; + Printf("First block not found\n"); + return 0; } @@ -1091,8 +920,7 @@ ULONG collectBlockListSFS(struct Volume *volume, ULONG objectnode, struct BlockN UBYTE * BTreeContainerPtr = NULL; BNodePtr = NULL; - _readwriteBlock(volume, nextblock, volume->blockbuffer, volume->SizeBlock<<2, - volume->readcmd); + readBlock(volume, nextblock, volume->blockbuffer, volume->SizeBlock); BTreeContainerPtr = (UBYTE*)(volume->blockbuffer + 3); /* Starts right after the header */ @@ -1115,8 +943,8 @@ ULONG collectBlockListSFS(struct Volume *volume, ULONG objectnode, struct BlockN if (BNodePtr == NULL) { D(bug("[install] collectBlockListSFS: Failed to travers extentbnode tree.\n")); - Printf("Failed to travers extentbnode tree.\n"); - return 0; + Printf("Failed to travers extentbnode tree.\n"); + return 0; } /* If we are at the leaf, stop */ @@ -1135,23 +963,23 @@ ULONG collectBlockListSFS(struct Volume *volume, ULONG objectnode, struct BlockN blk_count--; /* Check if we still have spece left to add data to BlockList */ - if ((blk_count-1) <= -BLCKLIST_ELEMENTS) - { + if ((blk_count-1) <= -BLCKLIST_ELEMENTS) + { D(bug("[install] collectBlockListSFS: ERROR: out of block space\n")); - Printf("There is no more space to save blocklist in core.img\n"); - return 0; - } + Printf("There is no more space to save blocklist in core.img\n"); + return 0; + } - blocklist[blk_count].sector_lo = searchedblock; - blocklist[blk_count].sector_hi = 0; - blocklist[blk_count].count = AROS_BE2WORD(((UWORD*)(BNodePtr + 12))[0]); + blocklist[blk_count].sector_lo = searchedblock; + blocklist[blk_count].sector_hi = 0; + blocklist[blk_count].count = AROS_BE2WORD(((UWORD*)(BNodePtr + 12))[0]); /* Handling of special situations */ if (searchedblock == first_block) { /* Writting first pack of blocks. Pointer needs to point to second file block */ - blocklist[blk_count].sector_lo++; - blocklist[blk_count].count--; + blocklist[blk_count].sector_lo++; + blocklist[blk_count].count--; if (blocklist[blk_count].count == 0) { /* This means that the first pack of blocks contained only one block - first block */ @@ -1173,18 +1001,18 @@ ULONG collectBlockListSFS(struct Volume *volume, ULONG objectnode, struct BlockN /* Correct blocks for volume start */ - + /* Blocks in blocklist are relative to the first sector of the HD (not partition) */ - i = 0; - for (count=-1;count>=blk_count;count--) - { - blocklist[count].sector_lo += volume->startblock; - blocklist[count].seg_adr = 0x820 + (i*32); - i += blocklist[count].count; + i = 0; + for (count=-1;count>=blk_count;count--) + { + blocklist[count].sector_lo += volume->startblock; + blocklist[count].seg_adr = 0x820 + (i*32); + i += blocklist[count].count; D(bug("[install] collectBlockListFFS: correcting block %d for partition start\n", count)); D(bug("[install] collectBlockListFFS: sector : %ld seg_adr : %x\n", blocklist[count].sector_lo, blocklist[count].seg_adr)); - } + } first_block += volume->startblock; @@ -1198,7 +1026,7 @@ VOID flushFS(CONST_STRPTR path) UWORD i; for (i = 0; path[i] != ':'; i++) - devname[i] = path[i]; + devname[i] = path[i]; devname[i++] = ':'; devname[i] = '\0'; @@ -1222,64 +1050,70 @@ VOID flushFS(CONST_STRPTR path) BOOL writeCoreIMG(BPTR fh, UBYTE *buffer, struct Volume *volume) { BOOL retval = FALSE; - LONG error; + if (myargs[ARG_TESTING]) + return TRUE; + D(bug("[install] writeCoreIMG(%x)\n", volume)); - if (Seek(fh, 0, OFFSET_BEGINNING) != -1) - { + if (Seek(fh, 0, OFFSET_BEGINNING) != -1) + { D(bug("[install] writeCoreIMG - write first block\n")); - /* write back first block */ - if (Write(fh, buffer, 512) == 512) - { + /* write back first block */ + if (Write(fh, buffer, 512) == 512) + { - /* read second core.img block */ - if (Read(fh, buffer, 512) == 512) - { - /* set partition number where core.img is on */ - /* FIXME: set RDB part number of DH? */ - UBYTE *install_boot_device = - buffer + GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE; - - D(bug("[install] set dos part = %d\n", volume->partnum)); - - install_boot_device[0] = 0; - install_boot_device[1] = 0; - install_boot_device[2] = volume->partnum; - - /* write second core.img block back */ - if (Seek(fh, -512, OFFSET_CURRENT) != -1) - { - if (Write(fh, buffer, 512) == 512) - { - retval = TRUE; - } - else - Printf("Write Error\n"); - } - else - Printf("Seek Error\n"); - } - else - Printf("Read Error\n"); - } - else - Printf("Write Error\n"); - } - else + /* read second core.img block */ + if (Read(fh, buffer, 512) == 512) + { + /* set partition number where core.img is on */ + LONG dos_part = 0; + LONG bsd_part = 0; /*?? to fix = RDB part number of DH? */ + LONG *install_dos_part = + (LONG *) (buffer + GRUB_KERNEL_MACHINE_INSTALL_DOS_PART); + LONG *install_bsd_part = + (LONG *) (buffer + GRUB_KERNEL_MACHINE_INSTALL_BSD_PART); + + dos_part = volume->partnum; + + D(bug("[install] set dos part = %d\n", dos_part)); + D(bug("[install] set bsd part = %d\n", bsd_part)); + + *install_dos_part = dos_part; + *install_bsd_part = bsd_part; + + /* write second core.img block back */ + if (Seek(fh, -512, OFFSET_CURRENT) != -1) + { + if (Write(fh, buffer, 512) == 512) + { + retval = TRUE; + } + else + Printf("Write Error\n"); + } + else + Printf("Seek Error\n"); + } + else + Printf("Read Error\n"); + } + else + Printf("Write Error\n"); + } + else { - error = IoErr(); Printf("Seek Error\n"); - PrintFault(error, NULL); + PrintFault(IoErr(), NULL); } - return retval; + return retval; } ULONG updateCoreIMG(CONST_STRPTR grubpath, /* path of grub dir */ - struct Volume *volume, /* volume core.img is on */ - ULONG *buffer /* a buffer of at least 512 bytes */) + struct Volume *volume, /* volume core.img is on */ + ULONG *buffer /* a buffer of at least 512 bytes */) { ULONG block = 0; struct FileInfoBlock fib; @@ -1288,28 +1122,28 @@ ULONG updateCoreIMG(CONST_STRPTR grubpath, /* path of grub dir */ D(bug("[install] updateCoreIMG(%x)\n", volume)); - AddPart(coreimgpath, grubpath, 256); - AddPart(coreimgpath, CORE_IMG_FILE_NAME, 256); - fh = Open(coreimgpath, MODE_OLDFILE); - if (fh) - { - if (ExamineFH(fh, &fib)) - { - if (Read(fh, buffer, 512) == 512) - { - /* - Get and store all blocks of core.img in first block of core.img. - First block of core.img will be returned. + AddPart(coreimgpath, grubpath, 256); + AddPart(coreimgpath, CORE_IMG_FILE_NAME, 256); + fh = Open(coreimgpath, MODE_OLDFILE); + if (fh) + { + if (ExamineFH(fh, &fib)) + { + if (Read(fh, buffer, 512) == 512) + { + /* + Get and store all blocks of core.img in first block of core.img. + First block of core.img will be returned. List of BlockNode starts at 512 - sizeof(BlockNode). List grows downwards. buffer is ULONG, buffer[128] is one pointer after first element(upwards). collectBlockList assumes it receives one pointer after first element(upwards). - */ + */ if (volume->dos_id == ID_SFS_BE_DISK) { D(bug("[install] core.img on SFS file system\n")); - block = collectBlockListSFS - (volume, fib.fib_DiskKey, (struct BlockNode *)&buffer[128]); + block = collectBlockListSFS + (volume, fib.fib_DiskKey, (struct BlockNode *)&buffer[128]); } else if ((volume->dos_id == ID_FFS_DISK) || (volume->dos_id == ID_INTER_DOS_DISK) || @@ -1318,7 +1152,7 @@ ULONG updateCoreIMG(CONST_STRPTR grubpath, /* path of grub dir */ { D(bug("[install] core.img on FFS file system\n")); block = collectBlockListFFS - (volume, fib.fib_DiskKey, (struct BlockNode *)&buffer[128]); + (volume, fib.fib_DiskKey, (struct BlockNode *)&buffer[128]); } else { @@ -1329,31 +1163,31 @@ ULONG updateCoreIMG(CONST_STRPTR grubpath, /* path of grub dir */ D(bug("[install] core.img first block: %ld\n", block)); - if (block) - { - if (!writeCoreIMG(fh, (UBYTE *)buffer, volume)) - block = 0; - } - } - else - Printf("%s: Read Error\n", coreimgpath); - } - else - PrintFault(IoErr(), coreimgpath); - - Close(fh); + if (block) + { + if (!writeCoreIMG(fh, (UBYTE *)buffer, volume)) + block = 0; + } + } + else + Printf("%s: Read Error\n", coreimgpath); + } + else + PrintFault(IoErr(), coreimgpath); + + Close(fh); - } - else - PrintFault(IoErr(), coreimgpath); - return block; + } + else + PrintFault(IoErr(), coreimgpath); + return block; } /* Installs boot.img to MBR and updates core.img */ -BOOL installGrubFiles(struct Volume *coreimgvol, /* core.img volume */ - CONST_STRPTR grubpath, /* path to grub files */ - ULONG unit, /* unit core.img is on */ - struct Volume *bootimgvol) /* boot device for boot.img */ +BOOL installGrubFiles(struct Volume *coreimgvol, /* core.img volume */ + CONST_STRPTR grubpath, /* path to grub files */ + ULONG unit, /* unit core.img is on */ + struct Volume *bootimgvol) /* boot device for boot.img */ { BOOL retval = FALSE; TEXT bootimgpath[256]; @@ -1368,13 +1202,13 @@ BOOL installGrubFiles(struct Volume *coreimgvol, /* core.img volume */ if (block) { - AddPart(bootimgpath, grubpath, 256); - AddPart(bootimgpath, (CONST_STRPTR) "i386-pc/boot.img", 256); - if (writeBootIMG(bootimgpath, bootimgvol, coreimgvol, block, unit)) - retval = TRUE; + AddPart(bootimgpath, grubpath, 256); + AddPart(bootimgpath, (CONST_STRPTR) "boot.img", 256); + if (writeBootIMG(bootimgpath, bootimgvol, coreimgvol, block, unit)) + retval = TRUE; } else - bug("failed %d\n", IoErr()); + bug("failed %d\n", IoErr()); return retval; } @@ -1387,78 +1221,91 @@ int main(int argc, char **argv) struct FileSysStartupMsg *fssm; int ret = RETURN_OK; + PartitionBase = (struct PartitionBase *)OpenLibrary("partition.library", 3); + if (!PartitionBase) + { + Printf("Failed to open partition.library v3!\n"); + return 20; + } + D(bug("[install] main()\n")); rdargs = ReadArgs(template, myargs, NULL); if (rdargs) { - CONST_STRPTR bootDevice = (CONST_STRPTR) myargs[0]; - LONG unit = *(LONG *) myargs[1]; - LONG *partnum = (LONG *) myargs[2]; - CONST_STRPTR grubpath = (CONST_STRPTR) myargs[3]; - - D(bug("[install] FORCELBA = %d\n", myargs[4])); - if (myargs[4]) - Printf("FORCELBA ignored\n"); - - if (partnum) - { - Printf("PARTITIONNUMBER not supported yet\n"); - FreeArgs(rdargs); - return RETURN_ERROR; - } - - fssm = getDiskFSSM(grubpath); - if (fssm != NULL) - { - CONST_STRPTR grubDevice = AROS_BSTR_ADDR(fssm->fssm_Device); - - if (!strcmp((const char *) grubDevice, (const char *) bootDevice)) - { - struct DosEnvec *dosEnvec; - dosEnvec = (struct DosEnvec *) BADDR(fssm->fssm_Environ); - - grubvol = getGrubStageVolume(grubDevice, fssm->fssm_Unit, - fssm->fssm_Flags, dosEnvec); - if (grubvol) - { - - bbvol = getBBVolume(bootDevice, unit, partnum); - if (bbvol) - { - if (!installGrubFiles(grubvol, grubpath, - fssm->fssm_Unit, bbvol)) - ret = RETURN_ERROR; - - uninitVolume(bbvol); - } - else - { - D(bug("getBBVolume failed miserably\n")); - ret = RETURN_ERROR; - } - - uninitVolume(grubvol); - } - } - else - { - Printf("%s is not on device %s unit %ld\n", - grubpath, bootDevice, (long)unit); - ret = RETURN_ERROR; - } - } - else if (fssm) - { - Printf("kernel path must begin with a device name\n"); - FreeArgs(rdargs); - ret = RETURN_ERROR; - } - - FreeArgs(rdargs); + CONST_STRPTR bootDevice = (CONST_STRPTR) myargs[0]; + LONG unit = *(LONG *) myargs[1]; + LONG *partnum = (LONG *) myargs[2]; + CONST_STRPTR grubpath = (CONST_STRPTR) myargs[3]; + + D(bug("[install] FORCELBA = %d\n", myargs[4])); + if (myargs[4]) + Printf("FORCELBA ignored\n"); + if (myargs[ARG_TESTING]) + Printf("Test mode. No data will be changed!\n"); + + if (partnum) + { + Printf("PARTITIONNUMBER not supported yet\n"); + FreeArgs(rdargs); + return RETURN_ERROR; + } + + fssm = getDiskFSSM(grubpath); + if (fssm != NULL) + { + CONST_STRPTR grubDevice = AROS_BSTR_ADDR(fssm->fssm_Device); + + if (!strcmp((const char *) grubDevice, (const char *) bootDevice)) + { + struct DosEnvec *dosEnvec; + dosEnvec = (struct DosEnvec *) BADDR(fssm->fssm_Environ); + + grubvol = getGrubStageVolume(grubDevice, fssm->fssm_Unit, + fssm->fssm_Flags, dosEnvec); + if (grubvol) + { + DumpVolume(grubvol, "GRUB volume"); + + bbvol = getBBVolume(bootDevice, unit, partnum); + if (bbvol) + { + DumpVolume(bbvol, "Bootblock volume"); + + if (!installGrubFiles(grubvol, grubpath, + fssm->fssm_Unit, bbvol)) + ret = RETURN_ERROR; + + uninitVolume(bbvol); + } + else + { + D(bug("getBBVolume failed miserably\n")); + ret = RETURN_ERROR; + } + + uninitVolume(grubvol); + } + } + else + { + Printf("%s is not on device %s unit %ld\n", + grubpath, bootDevice, (long)unit); + ret = RETURN_ERROR; + } + } + else if (fssm) + { + Printf("kernel path must begin with a device name\n"); + FreeArgs(rdargs); + ret = RETURN_ERROR; + } + + FreeArgs(rdargs); } else - PrintFault(IoErr(), (STRPTR) argv[0]); + PrintFault(IoErr(), (STRPTR) argv[0]); + CloseLibrary(&PartitionBase->lib); return ret; } diff --git a/arch/all-pc/boot/grub2-tools/mmakefile.src b/arch/all-pc/boot/grub2-tools/mmakefile.src index a173788fef..94d3e611e1 100644 --- a/arch/all-pc/boot/grub2-tools/mmakefile.src +++ b/arch/all-pc/boot/grub2-tools/mmakefile.src @@ -1,18 +1,15 @@ -# Copyright © 2003-2019, The AROS Development Team. All rights reserved. +# Copyright © 2003-2011, The AROS Development Team. All rights reserved. # $Id$ include $(SRCDIR)/config/aros.cfg -#MM- workbench-c : grub2-aros-installer -#MM- workbench-c-quick : grub2-aros-installer-quick - FILES := Install-grub2 USER_CPPFLAGS := -DADATE="\"$(shell date "+%d.%m.%Y")\"" USER_INCLUDES := -isystem $(SRCDIR)/arch/all-pc/boot/grub2-aros/include -%build_prog mmake=grub2-aros-installer \ - progname=Install-grub2 files=$(FILES) targetdir=$(AROS_C) \ +%build_progs mmake=workbench-c-install-grub2 \ + files=$(FILES) targetdir=$(AROS_C) \ uselibs="debug" %common diff --git a/arch/all-unix/filesys/emul_handler/emul_host.h b/arch/all-unix/filesys/emul_handler/emul_host.h index 70b7bd9716..a7fa7ab417 100644 --- a/arch/all-unix/filesys/emul_handler/emul_host.h +++ b/arch/all-unix/filesys/emul_handler/emul_host.h @@ -1,6 +1,10 @@ #ifndef RESOURCES_EMUL_HOST_H #define RESOURCES_EMUL_HOST_H +/* avoid conflicts between our __unused define and the ones that might come in + via sys/stat.h */ +#undef __unused + #include #include #include diff --git a/arch/all-unix/filesys/emul_handler/emul_unix.h b/arch/all-unix/filesys/emul_handler/emul_unix.h index 4691d5eab3..8d09471dac 100644 --- a/arch/all-unix/filesys/emul_handler/emul_unix.h +++ b/arch/all-unix/filesys/emul_handler/emul_unix.h @@ -1,5 +1,5 @@ /* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. + Copyright © 1995-2015, The AROS Development Team. All rights reserved. $Id$ */ @@ -7,14 +7,6 @@ #pragma pack(4) #endif -#ifdef HOST_UNDEF_UNUSED -/* - some linux hosts use __unused as a structure element name - in bits/stat.h, so we need to undefine it in that case -*/ -#undef __unused -#endif - #include #include #include diff --git a/arch/all-unix/filesys/emul_handler/mmakefile.src b/arch/all-unix/filesys/emul_handler/mmakefile.src index 3dada8b7ce..3a5f51a791 100644 --- a/arch/all-unix/filesys/emul_handler/mmakefile.src +++ b/arch/all-unix/filesys/emul_handler/mmakefile.src @@ -13,10 +13,6 @@ ifeq ($(ARCH),darwin) USER_CPPFLAGS += -D_FORTIFY_SOURCE=0 endif -ifeq ($(HOST_STAT_H_FIXUP),yes) -USER_CPPFLAGS += -DHOST_UNDEF_UNUSED -endif - FILES := emul_host_unix emul_host emul_dir %build_archspecific mainmmake=kernel-fs-emul \ diff --git a/arch/arm-raspi/boot/boot.c b/arch/arm-raspi/boot/boot.c index 176d4c3f0b..438c319dfe 100644 --- a/arch/arm-raspi/boot/boot.c +++ b/arch/arm-raspi/boot/boot.c @@ -392,11 +392,8 @@ void boot(uintptr_t dummy, uintptr_t arch, struct tag * atags, uintptr_t a) uint32_t size_ro, size_rw; /* Calculate total size of kernel and modules */ -#if AROS_BIG_ENDIAN - getElfSize(&_binary_core_be_bin_start, &size_rw, &size_ro); -#else getElfSize(&_binary_core_bin_start, &size_rw, &size_ro); -#endif + total_size_ro = size_ro = (size_ro + 4095) & ~4095; total_size_rw = size_rw = (size_rw + 4095) & ~4095; @@ -505,11 +502,7 @@ void boot(uintptr_t dummy, uintptr_t arch, struct tag * atags, uintptr_t a) boottag->ti_Data = kernel_phys; boottag++; -#if AROS_BIG_ENDIAN - loadElf(&_binary_core_be_bin_start); -#else loadElf(&_binary_core_bin_start); -#endif if (pkg_image && pkg_size) { diff --git a/arch/arm-raspi/boot/elf.c b/arch/arm-raspi/boot/elf.c index c1270f4070..65558af692 100644 --- a/arch/arm-raspi/boot/elf.c +++ b/arch/arm-raspi/boot/elf.c @@ -68,7 +68,7 @@ int checkHeader(struct elfheader *eh) ( eh->ident[EI_CLASS] != ELFCLASS32 || eh->ident[EI_VERSION] != EV_CURRENT || - !(eh->type == ET_REL || eh->type == ET_EXEC) || + eh->type != ET_REL || #if AROS_BIG_ENDIAN eh->ident[EI_DATA] != ELFDATA2MSB || #else @@ -210,12 +210,11 @@ static int load_hunk(void *file, struct sheader *sh) /* Perform relocations of given section */ static int relocate(struct elfheader *eh, struct sheader *sh, long shrel_idx, - uint32_t virt, uintptr_t *deltas) + uint32_t virt) { struct sheader *shrel = &sh[shrel_idx]; struct sheader *shsymtab = &sh[shrel->link]; struct sheader *toreloc = &sh[shrel->info]; - uintptr_t orig_addr = deltas[shrel->info]; int is_exec = (eh->type == ET_EXEC); struct symbol *symtab = @@ -234,7 +233,7 @@ static int relocate(struct elfheader *eh, struct sheader *sh, long shrel_idx, for (i = 0; i < numrel; i++, rel++) { struct symbol *sym = &symtab[ELF32_R_SYM(rel->info)]; - uint32_t *p = (uint32_t *) & section[rel->offset - orig_addr]; + uint32_t *p = (uint32_t *) & section[rel->offset]; uint32_t s; virtoffset = virt; @@ -398,7 +397,6 @@ kprintf("movw/movt: offset=%08x, s=%08x, sym->value=%08x, section_orig_addr=%08x int loadElf(void *elf_file) { struct elfheader *eh = (struct elfheader *)elf_file; - uintptr_t deltas[int_shnum]; //uint32_t s_ro = 0; //uint32_t s_rw = 0; @@ -419,7 +417,6 @@ int loadElf(void *elf_file) /* Does the section require memoy allcation? */ else if (sh[i].flags & SHF_ALLOC) { - deltas[i] = (uintptr_t)sh[i].addr; /* Yup, it does. Load the hunk */ if (!load_hunk(elf_file, &sh[i])) { @@ -429,11 +426,10 @@ int loadElf(void *elf_file) { if (sh[i].size) { - DELF(kprintf("[BOOT:ELF] %s section loaded at %p (Virtual addr: %p, requestet addr: %p)\n", + DELF(kprintf("[BOOT:ELF] %s section loaded at %p (Virtual addr: %p)\n", sh[i].flags & SHF_WRITE ? "RW":"RO", sh[i].addr, - sh[i].addr + virtoffset, - deltas[i])); + sh[i].addr + virtoffset)); } } } @@ -445,7 +441,7 @@ int loadElf(void *elf_file) if (sh[i].type == SHT_REL && sh[sh[i].info].addr) { sh[i].addr = (APTR)((uint32_t) elf_file + sh[i].offset); - if (!sh[i].addr || !relocate(eh, sh, i, virtoffset, deltas)) + if (!sh[i].addr || !relocate(eh, sh, i, virtoffset)) { return 0; } diff --git a/arch/arm-raspi/boot/include/boot.h b/arch/arm-raspi/boot/include/boot.h index f9ff6bda86..e94223d5dd 100644 --- a/arch/arm-raspi/boot/include/boot.h +++ b/arch/arm-raspi/boot/include/boot.h @@ -28,15 +28,9 @@ void arm_flush_cache(uint32_t addr, uint32_t length); extern uint8_t __bootstrap_start; extern uint8_t __bootstrap_end; -#if AROS_BIG_ENDIAN -extern void *_binary_core_be_bin_start; -extern long *_binary_core_be_bin_end; -extern long _binary_core_be_bin_size; -#else extern void *_binary_core_bin_start; extern long *_binary_core_bin_end; extern long _binary_core_bin_size; -#endif void kprintf(const char *format, ...); diff --git a/arch/arm-raspi/boot/mmakefile.src b/arch/arm-raspi/boot/mmakefile.src index 213edd01cb..e869e7bfe7 100644 --- a/arch/arm-raspi/boot/mmakefile.src +++ b/arch/arm-raspi/boot/mmakefile.src @@ -175,7 +175,7 @@ $(AROSDIR)/config.txt: $(AROSDIR)/$(ARM_BSP) @printf "kernel=aros-$(AROS_TARGET_CPU)-raspi.img\ninitramfs $(ARM_BSP) 0x00800000" > $@ $(AROSDIR)/aros-armeb-raspi.img: $(TARGETDIR)/core-be.bin.o $(foreach f, $(FILES), $(TARGETDIR)/$(f).o $(TARGETDIR)/$(f).d) - $(KERNEL_LD) --be8 --format elf32-bigarm -s --entry=bootstrap --script=$(SRCDIR)/$(CURDIR)/ldscript-be.lds $(foreach f, $(FILES), $(TARGETDIR)/$(f).o) $ $(TARGETDIR)/core-be.bin.o -L$(AROS_LIB) -lstdc.static -laeabi -o $(OSGENDIR)/boot/aros-armeb-raspi.img.elf + $(KERNEL_LD) --be8 --format elf32-bigarm -s --entry=bootstrap --script=$(SRCDIR)/$(CURDIR)/ldscript-be.lds $(foreach f, $(FILES), $(TARGETDIR)/$(f).o) $ $(TARGETDIR)/core.bin.o -L$(AROS_LIB) -lstdc.static -laeabi -o $(OSGENDIR)/boot/aros-armeb-raspi.img.elf $(TARGET_OBJCOPY) -O binary $(OSGENDIR)/boot/aros-armeb-raspi.img.elf $@ $(AROSDIR)/aros-arm-raspi.img: $(TARGETDIR)/core.bin.o $(foreach f, $(FILES), $(TARGETDIR)/$(f).o $(TARGETDIR)/$(f).d) diff --git a/arch/i386-pc/boot/floppy/mmakefile.src b/arch/i386-pc/boot/floppy/mmakefile.src index 13867cd90c..07dc24c8c8 100644 --- a/arch/i386-pc/boot/floppy/mmakefile.src +++ b/arch/i386-pc/boot/floppy/mmakefile.src @@ -36,7 +36,7 @@ BOOT_TAR_EXECUTABLES := \ C/MakeDir C/MakeLink C/Mount C/NewShell C/Path C/Prompt C/Protect C/Quit \ C/Reboot C/Relabel C/Rename C/Resident C/Run C/Search C/Set C/SetClock \ C/SetDate C/Setenv C/Skip C/Stack C/Status C/Touch C/Type C/Unalias \ - C/Unset C/Unsetenv C/Version C/Which C/Why C/Install-grub \ + C/Unset C/Unsetenv C/Version C/Which C/Why C/install-i386-pc \ C/Partition \ Classes/DataTypes/ascii.datatype \ Classes/DataTypes/binary.datatype \ diff --git a/arch/i386-pc/boot/grub2/grub-efi.cfg b/arch/i386-pc/boot/grub2/grub-efi.cfg index 8ecd354db5..ce0f8c8bb7 100644 --- a/arch/i386-pc/boot/grub2/grub-efi.cfg +++ b/arch/i386-pc/boot/grub2/grub-efi.cfg @@ -3,7 +3,7 @@ insmod efi_gop insmod efi_uga -if loadfont /EFI/BOOT/grub/fonts/unicode.pf2 ; then +if loadfont /EFI/BOOT/grub/unicode.pf2 ; then insmod gfxterm set gfxmode=640x480 terminal_output gfxterm diff --git a/arch/i386-pc/boot/grub2/grub.cfg b/arch/i386-pc/boot/grub2/grub.cfg index f37b61bffe..217c6d2e03 100644 --- a/arch/i386-pc/boot/grub2/grub.cfg +++ b/arch/i386-pc/boot/grub2/grub.cfg @@ -4,7 +4,7 @@ set timeout=5 # Set default boot entry as VESA Gfx @ 1024x768-32bpp set default=4 -if loadfont /boot/pc/grub/fonts/unicode.pf2 ; then +if loadfont /boot/pc/grub/unicode.pf2 ; then insmod vbe insmod gfxterm set gfxmode=640x480 diff --git a/arch/m68k-all/dos/mmakefile.src b/arch/m68k-all/dos/mmakefile.src index efed97df38..8641260155 100644 --- a/arch/m68k-all/dos/mmakefile.src +++ b/arch/m68k-all/dos/mmakefile.src @@ -15,7 +15,7 @@ AFILES := callentry \ USER_INCLUDES := -I$(SRCDIR)/arch/$(CPU)-$(ARCH)/dos \ -I$(SRCDIR)/rom/dos -USER_CPPFLAGS := -D__DOS_NOLIBBASE__ +USER_CFLAGS := -D__DOS_NOLIBBASE__ USER_AFLAGS := -I$(GENINCDIR) diff --git a/arch/m68k-all/exec/alert_cpu.c b/arch/m68k-all/exec/alert_cpu.c index a5efc8972d..f05c183f33 100644 --- a/arch/m68k-all/exec/alert_cpu.c +++ b/arch/m68k-all/exec/alert_cpu.c @@ -1,5 +1,5 @@ /* - Copyright © 2010-2019, The AROS Development Team. All rights reserved. + Copyright © 2010-2018, The AROS Development Team. All rights reserved. $Id$ Desc: CPU context parsing routines. @@ -36,7 +36,7 @@ char *FormatCPUContext(char *buffer, struct ExceptionContext *ctx, struct ExecBa "A0: %08lx %08lx %08lx %08lx\n" "A4: %08lx %08lx %08lx %08lx\n" "SR: %04x\n" - "PC: %08lx\n", (RAWARG)ctx, dest, buffer); + "PC: %08lx", (RAWARG)ctx, dest, buffer); buf = buffer + strlen(buffer); segSem = (struct SegSem *)FindSemaphore(SEG_SEM); @@ -52,7 +52,7 @@ char *FormatCPUContext(char *buffer, struct ExceptionContext *ctx, struct ExecBa AROS_UFCA(ULONG, ctx->pc, A0), AROS_UFCA(ULONG*, &SegList, A1), AROS_UFCA(ULONG*, &SegList, A2)); - buf = NewRawDoFmt("SegTracker: %s\nHunk %ld, Offset $%08lx, SegList $%08lx\n", dest, buf, name, SegNum, SegOffset, SegList); + buf = NewRawDoFmt("\nSegTracker: %s\nHunk %ld, Offset $%08lx, SegList $%08lx\n", dest, buf, name, SegNum, SegOffset, SegList); } Permit(); } diff --git a/arch/m68k-all/include/gencall.c b/arch/m68k-all/include/gencall.c index 50cb01549c..2fdcb82310 100644 --- a/arch/m68k-all/include/gencall.c +++ b/arch/m68k-all/include/gencall.c @@ -1,11 +1,11 @@ /* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. + Copyright © 1995-2001, The AROS Development Team. All rights reserved. $Id$ */ -/* This program generates the libcall.h macroset for m68k-elf +/* This program generates the libcall.h macroset for gcc-4.5.1 m68k-elf * - * WARNING: The header generated by this program has only been - * tested to work with GCC 4.5.1 to GCC 8.3.0 m68k-elf ONLY. + * WARNING: The header generated by this program is designed + * to work with GCC 4.5.1 and GCC 4.6.1 m68k-elf ONLY. * * If it breaks, you get to keep both pieces. */ @@ -546,7 +546,9 @@ int main(int argc, char **argv) if (strcmp(argv[1], "asmcall") == 0) { - printf("/*\n Copyright \xa9 2019, The AROS Development Team. All rights reserved.\n This file is AUTOGENERATED from arch/m68k-all/include/gencall.c\n*/\n"); + printf("/* AUTOGENERATED by arch/m68k-all/include/gencall.c */\n"); + printf("/* If you can get this to work for anything other */\n"); + printf("/* than gcc-4.5.1 m68k-elf, it would be surprising. */\n"); printf("\n"); printf("#ifndef AROS_M68K_ASMCALL_H\n"); printf("#define AROS_M68K_ASMCALL_H\n"); @@ -578,7 +580,9 @@ int main(int argc, char **argv) } else if (strcmp(argv[1], "libcall") == 0) { - printf("/*\n Copyright \xa9 2019, The AROS Development Team. All rights reserved.\n This file is AUTOGENERATED from arch/m68k-all/include/gencall.c\n*/\n"); + printf("/* AUTOGENERATED by arch/m68k-all/include/gencall.c */\n"); + printf("/* If you can get this to work for anything other */\n"); + printf("/* than gcc-4.5.1 m68k-elf, it would be surprising. */\n"); printf("\n"); printf("#ifndef AROS_M68K_LIBCALL_H\n"); printf("#define AROS_M68K_LIBCALL_H\n"); diff --git a/arch/m68k-all/kernel/kernel_cpu.c b/arch/m68k-all/kernel/kernel_cpu.c index 877d4b63df..8ca718684e 100644 --- a/arch/m68k-all/kernel/kernel_cpu.c +++ b/arch/m68k-all/kernel/kernel_cpu.c @@ -42,8 +42,6 @@ void cpu_Switch(regs_t *regs) struct Task *task = SysBase->ThisTask; struct AROSCPUContext *ctx = task->tc_UnionETask.tc_ETask->et_RegFrame; - D(bug("[Kernel] %s: Switching ThisTask=0x%p '%s'\n", __func__, task, task->tc_Node.ln_Name);) - /* Actually save the context */ CopyMem(regs, &ctx->cpu, sizeof(regs_t)); @@ -70,45 +68,8 @@ void cpu_Dispatch(regs_t *regs) task = core_Dispatch(); if (task != NULL) break; - D( - bug("[Kernel] %s: TASK QUEUE EMPTY!!\n", __func__); - - // Dump tasks ... - if (SysBase->ThisTask) - { - bug("[Kernel] %s: ThisTask=0x%p '%s'\n", __func__, SysBase->ThisTask, SysBase->ThisTask->tc_Node.ln_Name); - bug("[Kernel] %s: tc_Flags = %x\n", __func__, SysBase->ThisTask->tc_Flags); - bug("[Kernel] %s: tc_State = %x\n", __func__, SysBase->ThisTask->tc_State); - bug("[Kernel] %s: tc_SigAlloc = %x\n", __func__, SysBase->ThisTask->tc_SigAlloc); - bug("[Kernel] %s: tc_SigWait = %x\n", __func__, SysBase->ThisTask->tc_SigWait); - bug("[Kernel] %s: tc_SigRecv = %x\n", __func__, SysBase->ThisTask->tc_SigRecv); - bug("[Kernel] %s: tc_IDNestCnt = %d\n", __func__, SysBase->ThisTask->tc_IDNestCnt); - bug("[Kernel] %s: tc_TDNestCnt = %d\n", __func__, SysBase->ThisTask->tc_TDNestCnt); - } - - ForeachNode(&SysBase->TaskReady, task) - { - bug("[Kernel] %s: Ready Task @ 0x%p '%s'\n", __func__, task, task->tc_Node.ln_Name); - bug("[Kernel] %s: tc_Flags = %x\n", __func__, task->tc_Flags); - bug("[Kernel] %s: tc_State = %x\n", __func__, task->tc_State); - bug("[Kernel] %s: tc_SigAlloc = %x\n", __func__, task->tc_SigAlloc); - bug("[Kernel] %s: tc_SigWait = %x\n", __func__, task->tc_SigWait); - bug("[Kernel] %s: tc_SigRecv = %x\n", __func__, task->tc_SigRecv); - bug("[Kernel] %s: tc_IDNestCnt = %d\n", __func__, task->tc_IDNestCnt); - bug("[Kernel] %s: tc_TDNestCnt = %d\n", __func__, task->tc_TDNestCnt); - } - ForeachNode(&SysBase->TaskWait, task) - { - bug("[Kernel] %s: Waiting Task @ 0x%p '%s'\n", __func__, task, task->tc_Node.ln_Name); - bug("[Kernel] %s: tc_Flags = %x\n", __func__, task->tc_Flags); - bug("[Kernel] %s: tc_State = %x\n", __func__, task->tc_State); - bug("[Kernel] %s: tc_SigAlloc = %x\n", __func__, task->tc_SigAlloc); - bug("[Kernel] %s: tc_SigWait = %x\n", __func__, task->tc_SigWait); - bug("[Kernel] %s: tc_SigRecv = %x\n", __func__, task->tc_SigRecv); - bug("[Kernel] %s: tc_IDNestCnt = %d\n", __func__, task->tc_IDNestCnt); - bug("[Kernel] %s: tc_TDNestCnt = %d\n", __func__, task->tc_TDNestCnt); - } - ) + D(bug("-- IDLE HALT --\n")); + /* Break IDNestCnt */ if (SysBase->IDNestCnt >= 0) { SysBase->IDNestCnt=-1; @@ -117,8 +78,6 @@ void cpu_Dispatch(regs_t *regs) asm volatile ("stop #0x2000\n"); // Wait for an interrupt } - D(bug("[Kernel] %s: Dispatching Task @ 0x%p '%s'\n", __func__, task, task->tc_Node.ln_Name);) - ctx = task->tc_UnionETask.tc_ETask->et_RegFrame; CopyMem(&ctx->cpu, regs, sizeof(regs_t)); regs->a[7] = (IPTR)task->tc_SPReg; diff --git a/arch/m68k-all/kernel/m68k_exception.c b/arch/m68k-all/kernel/m68k_exception.c index 07fd9dc5db..3dbdc288f6 100644 --- a/arch/m68k-all/kernel/m68k_exception.c +++ b/arch/m68k-all/kernel/m68k_exception.c @@ -301,8 +301,6 @@ AROS_UFH2(VOID, M68KExceptionAction, } #endif - D(kprintf("[Kernel] %s(%d)\n", __func__, Id);) - tc->traparg = Id; if (!Handler) { Handler = FindTask(NULL)->tc_TrapCode; diff --git a/arch/m68k-all/libgcc1/mmakefile.src b/arch/m68k-all/libgcc1/mmakefile.src index 14af047bc9..e60573ffbe 100644 --- a/arch/m68k-all/libgcc1/mmakefile.src +++ b/arch/m68k-all/libgcc1/mmakefile.src @@ -1,6 +1,6 @@ include $(SRCDIR)/config/aros.cfg -TARGET_ISA_AFLAGS:=$(ISA_MC68020_FLAGS) +USER_AFLAGS := -mc68020 %rule_assemble_multi \ basenames="_addsubdf3 _addsubsf3 _divdf3 _divmodsi3 divsf3 _eqdf2 _eqsf2 _extend _extendsfdf2 _fixdfsi _fixsfsi _floatsidf _floatsisf _gedf2 _gesf2 _gtdf2 _gtsf2 _ledf2 _lesf2 _ltdf2 _ltsf2 _muldf3 _mulsf3 _mulsi3 _nedf2 _negdf2 _negsf2 _nesf2 _normdf _normsf _truncdfsf2 _udivmodsi3" aflags="-mc68020" diff --git a/arch/m68k-all/mathieeedoubbas/mmakefile.src b/arch/m68k-all/mathieeedoubbas/mmakefile.src index 5f0cd8c7f2..3ddf094844 100644 --- a/arch/m68k-all/mathieeedoubbas/mmakefile.src +++ b/arch/m68k-all/mathieeedoubbas/mmakefile.src @@ -6,8 +6,7 @@ FILES := ieeedpbas_fpu mathieeedoubbas_init AFILES := fpu USER_INCLUDES := -I$(SRCDIR)/workbench/libs/mathieeedoubbas -USER_AFLAGS := -I$(GENINCDIR) -TARGET_ISA_AFLAGS:=$(ISA_MC68040_FLAGS) +USER_AFLAGS := -I$(GENINCDIR) -march=68040 %build_archspecific \ mainmmake=workbench-libs-mathieeedoubbas modname=mathieeedoubbas maindir=workbench/libs/mathieeedoubbas arch=m68k \ diff --git a/arch/m68k-all/mathieeedoubtrans/mmakefile.src b/arch/m68k-all/mathieeedoubtrans/mmakefile.src index 25a6fe6345..09683333e5 100644 --- a/arch/m68k-all/mathieeedoubtrans/mmakefile.src +++ b/arch/m68k-all/mathieeedoubtrans/mmakefile.src @@ -6,8 +6,7 @@ FILES := ieeedptrans_fpu mathieeedoubtrans_init AFILES := fpu USER_INCLUDES := -I$(SRCDIR)/workbench/libs/mathieeedoubtrans -USER_AFLAGS := -I$(GENINCDIR) -TARGET_ISA_AFLAGS:=$(ISA_MC68040_FLAGS) +USER_AFLAGS := -I$(GENINCDIR) -march=68040 %build_archspecific \ mainmmake=workbench-libs-mathieeedoubtrans modname=mathieeedoubtrans maindir=workbench/libs/mathieeedoubtrans arch=m68k \ diff --git a/arch/m68k-all/mathieeesingbas/mmakefile.src b/arch/m68k-all/mathieeesingbas/mmakefile.src index cda6ed5d5e..f01fdb3345 100644 --- a/arch/m68k-all/mathieeesingbas/mmakefile.src +++ b/arch/m68k-all/mathieeesingbas/mmakefile.src @@ -6,8 +6,7 @@ FILES := mathieeesingbas_init AFILES := fpu USER_INCLUDES := -I$(SRCDIR)/workbench/libs/mathieeesingbas -USER_AFLAGS := -I$(GENINCDIR) -TARGET_ISA_AFLAGS:=$(ISA_MC68040_FLAGS) +USER_AFLAGS := -I$(GENINCDIR) -march=68040 %build_archspecific \ mainmmake=workbench-libs-mathieeesingbas modname=mathieeesingbas maindir=workbench/libs/mathieeesingbas arch=m68k \ diff --git a/arch/m68k-all/mathieeesingtrans/mmakefile.src b/arch/m68k-all/mathieeesingtrans/mmakefile.src index 7728672322..5f4696cda9 100644 --- a/arch/m68k-all/mathieeesingtrans/mmakefile.src +++ b/arch/m68k-all/mathieeesingtrans/mmakefile.src @@ -6,9 +6,7 @@ FILES := mathieeesingtrans_init AFILES := fpu USER_INCLUDES := -I$(SRCDIR)/workbench/libs/mathieeesingtrans -USER_AFLAGS := -I$(GENINCDIR) -TARGET_ISA_AFLAGS:=$(ISA_MC68040_FLAGS) - +USER_AFLAGS := -I$(GENINCDIR) -march=68040 %build_archspecific \ mainmmake=workbench-libs-mathieeesingtrans modname=mathieeesingtrans maindir=workbench/libs/mathieeesingtrans arch=m68k \ diff --git a/arch/m68k-amiga/boot/mmakefile.src b/arch/m68k-amiga/boot/mmakefile.src index cadda919b7..2addc4e239 100644 --- a/arch/m68k-amiga/boot/mmakefile.src +++ b/arch/m68k-amiga/boot/mmakefile.src @@ -4,10 +4,12 @@ include $(SRCDIR)/config/aros.cfg -#MM- kernel-link-amiga-m68k : \ -#MM general-setup-amiga-m68k \ -#MM kernel-bsp-objs \ -#MM kernel-objs \ +Q ?= @ + +#MM- kernel-link-amiga-m68k : \ +#MM general-setup-amiga-m68k \ +#MM kernel-bsp-objs \ +#MM kernel-objs \ #MM kernel-alerthook-kobj \ #MM kernel-amiga-m68k-amigavideo-kobj \ #MM kernel-amiga-m68k-audio-kobj \ @@ -15,7 +17,7 @@ include $(SRCDIR)/config/aros.cfg #MM kernel-amiga-m68k-devs \ #MM kernel-amiga-m68k-kbd-kobj \ #MM kernel-amiga-m68k-mouse-kobj \ -#MM kernel-amiga-m68k-p96gfx-kobj \ +#MM kernel-amiga-m68k-uaegfx-kobj \ #MM kernel-amiga-m68k-wbtag-kobj \ #MM kernel-aros-kobj \ #MM kernel-hidd-bus-kobj \ @@ -50,7 +52,7 @@ include $(SRCDIR)/config/aros.cfg #MM kernel-hidd-amigakbd-kobj \ #MM kernel-hidd-amigamouse-kobj \ #MM kernel-hidd-amigavideo-kobj \ -#MM kernel-hidd-p96gfx-kobj \ +#MM kernel-hidd-uaegfx-kobj \ #MM kernel-hidd-ata_gayle-kobj \ #MM kernel-intuition-kobj \ #MM kernel-input-kobj \ @@ -102,11 +104,9 @@ rom_entry.o: FORCE ext_entry.o: FORCE -USER_CPPFLAGS := -DADATE="\"$(shell date "+%d.%m.%Y")\"" -#USER_CPPFLAGS += -DDEFKRN_CMDLINE="\"nomonitors sysdebug=InitCode,debugmmu,mungwall\"" - # Use -m68060 when compiling .S files, as we will need the # expanded instruction set to detect alternate CPUs +USER_CPPFLAGS := -DADATE="\"$(shell date "+%d.%m.%Y")\"" TARGET_ISA_AFLAGS := $(ISA_MC68060_FLAGS) # Sadly, we need to consume Chip RAM for the initial SS and the ROM BSS. @@ -126,7 +126,7 @@ AFILES=rom_entry rom_init cpu_detect superstack_swap KLIBS := exec aros dos utility oop expansion partition debug KDEVS := timer input keyboard console trackdisk gameport audio KHNDLRS := con afs ram -KHIDDS := amigakbd amigamouse amigavideo ata_gayle gfx hiddclass keyboard mouse p96gfx +KHIDDS := amigakbd amigamouse amigavideo ata_gayle gfx hiddclass keyboard mouse uaegfx KRSRCS := battclock kernel processor task lddemon dosboot cia potgo disk FileSystem misc shell card bootloader KHOOKS := diag romboot @@ -139,8 +139,7 @@ KOBJS_rom := $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS))) \ $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) )) OBJS_rom := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \ - $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES))) - + $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES))) $(DISTDIR)/aros-amiga-m68k-rom.elf: $(KOBJS_rom) $(OBJS_rom) # Expansion ROM (0xe00000-0xe7ffff) @@ -165,10 +164,8 @@ KOBJS_ext := \ $(addprefix $(KOBJSDIR)/,$(addsuffix _resource.ko,$(KRSRCS) )) \ $(addprefix $(KOBJSDIR)/,$(addsuffix _driver.ko ,$(KDRVRS) )) \ $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) )) - OBJS_ext := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \ - $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES))) - + $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES))) $(DISTDIR)/aros-amiga-m68k-ext.elf: $(KOBJS_ext) $(OBJS_ext) #MM kernel-link-amiga-m68k: @@ -189,7 +186,7 @@ $(GENDIR)/%_objs.ld: $(SRCDIR)/$(CURDIR)/mmakefile.src $(DISTDIR)/aros-amiga-m68k-reloc.elf : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \ $(OBJS_rom) $(KOBJS_rom) \ - $(OBJS_ext) $(KOBJS_ext) \ + $(OBJS_ext) $(KOBJS_ext) \ $(SRCDIR)/$(CURDIR)/aros-rom.ld \ $(GENDIR)/rom_objs.ld \ $(GENDIR)/ext_objs.ld @@ -206,10 +203,10 @@ $(DISTDIR)/aros-amiga-m68k-reloc.elf : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile. $(DISTDIR)/aros-amiga-m68k.elf: $(DISTDIR)/aros-amiga-m68k-reloc.elf $(Q)$(KERNEL_LD) -o $@ \ - --section-start .rom=$(ROMLOC_rom) \ - --section-start .ext=$(ROMLOC_ext) \ - --section-start .ss=$(ROMLOC_ss) \ - $< + --section-start .rom=$(ROMLOC_rom) \ + --section-start .ext=$(ROMLOC_ext) \ + --section-start .ss=$(ROMLOC_ss) \ + $< $(Q)$(TARGET_OBJDUMP) -h $@ | grep '[rea][oxm][mte] ' $(DISTDIR)/aros-amiga-m68k-%.bin : $(DISTDIR)/aros-amiga-m68k.elf $(HOSTGENDIR)/tools/romcheck @@ -297,13 +294,13 @@ KOBJS_local := $(addprefix $(KOBJSDIR)/,$(addsuffix _library.ko ,$(KLIBS))) \ $(addprefix $(KOBJSDIR)/,$(addsuffix _hook.ko ,$(KHOOKS) )) OBJS_local:= $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \ - $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES))) + $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES))) FILES=start early debug AFILES=rom_entry rom_init cpu_detect superstack_swap OBJS_start := $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(AFILES))) \ - $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES))) + $(addprefix $(KOBJSDIR)/,$(addsuffix .o,$(FILES))) # Everything else. Can live in MEMF_ANY @@ -314,7 +311,7 @@ KLIBS := aros utility dos oop mathffp mathieeesingbas partition \ keymap graphics layers intuition gadtools icon workbench setpatch KDEVS := timer input keyboard console trackdisk gameport audio ata cd KHNDLRS := cdfs con afs ram -KHIDDS := amigakbd amigamouse amigavideo ata_gayle bus gfx hiddclass keyboard mouse storage system p96gfx +KHIDDS := amigakbd amigamouse amigavideo ata_gayle bus gfx hiddclass keyboard mouse storage system uaegfx KRSRCS := battclock processor task lddemon dosboot cia potgo disk \ misc shell shellcommands workbook wbtag card FileSystem KHOOKS := alert romboot @@ -331,7 +328,7 @@ KOBJS_any := \ $(DISTDIR)/aros-amiga-m68k-ram.elf : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \ $(OBJS_start) \ $(OBJS_local) $(KOBJS_local) \ - $(OBJS_any) $(KOBJS_any) \ + $(OBJS_any) $(KOBJS_any) \ $(SRCDIR)/$(CURDIR)/aros-ram.ld \ $(GENDIR)/start_objs.ld \ $(GENDIR)/local_objs.ld \ @@ -352,21 +349,21 @@ $(AROSARCHDIR)/aros.elf: $(DISTDIR)/aros-amiga-m68k-ram.elf \ $(SRCDIR)/$(CURDIR)/mmakefile.src $(Q)$(MKDIR) $(AROSARCHDIR) $(Q)$(TARGET_OBJCOPY) \ - --strip-unneeded \ - $< $@ + --strip-unneeded \ + $< $@ $(AROSARCHDIR)/aros.elf.dbg : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \ $(OBJS_start) \ $(OBJS_local) $(KOBJS_local) \ - $(OBJS_any) $(KOBJS_any) \ + $(OBJS_any) $(KOBJS_any) \ $(SRCDIR)/$(CURDIR)/aros-dbg.ld \ $(GENDIR)/start_objs.ld \ $(GENDIR)/local_objs.ld \ $(GENDIR)/any_objs.ld @$(IF) [ "$(DEBUG)" = "yes" ]; then \ - $(ECHO) Linking $@...; \ - $(KERNEL_CC) -Wl,-r \ + $(ECHO) Linking $@...; \ + $(KERNEL_CC) -Wl,-r \ -static -nostartfiles -nostdlib \ -Wl,--defsym -Wl,start=0x0 \ -Wl,--defsym -Wl,SysBase=0x4 \ @@ -374,7 +371,7 @@ $(AROSARCHDIR)/aros.elf.dbg : $(DEPLIBS) $(SRCDIR)/$(CURDIR)/mmakefile.src \ -m68000 \ -o $@ -Wl,-T -Wl,$(SRCDIR)/$(CURDIR)/aros-dbg.ld \ -L$(AROS_LIB) $(LIBS) -lgcc; \ - $(TARGET_OBJCOPY) --add-gnu-debuglink=$@ $(AROSARCHDIR)/aros.elf; \ + $(TARGET_OBJCOPY) --add-gnu-debuglink=$@ $(AROSARCHDIR)/aros.elf; \ fi diff --git a/arch/m68k-amiga/boot/start.c b/arch/m68k-amiga/boot/start.c index c43c996b0c..ae3cac4d0c 100644 --- a/arch/m68k-amiga/boot/start.c +++ b/arch/m68k-amiga/boot/start.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. + Copyright © 1995-2018, The AROS Development Team. All rights reserved. $Id$ Desc: m68k-amiga bootstrap to exec. @@ -32,18 +32,6 @@ #define SS_STACK_SIZE 0x02000 -/* nomonitors - Until we have working m68k PCI support, - * attempting to load the monitor drivers - * just wastes a lot of time during boot - */ - #ifndef DEFKRN_CMDLINE -#if AROS_SERIAL_DEBUG -#define DEFKRN_CMDLINE "nomonitors sysdebug=InitCode" -#else -#define DEFKRN_CMDLINE "nomonitors" -#endif -#endif - static BOOL iseven(APTR p) { return (((ULONG)p) & 1) == 0; @@ -655,10 +643,19 @@ static UWORD GetAttnFlags(ULONG *cpupcr) void exec_boot(ULONG *membanks, ULONG *cpupcr) { struct TagItem bootmsg[] = { - { KRN_CmdLine, (IPTR)DEFKRN_CMDLINE }, - { KRN_KernelStackBase, (IPTR)&_ss }, - { KRN_KernelStackSize, (IPTR)(&_ss_end - &_ss) }, - { TAG_END }, + /* nomonitors - Until we have working m68k PCI support, + * attempting to load the monitor drivers + * just wastes a lot of time during boot + */ +#if AROS_SERIAL_DEBUG + { KRN_CmdLine, (IPTR)"nomonitors sysdebug=InitCode" }, +// { KRN_CmdLine, (IPTR)"nomonitors sysdebug=InitCode,debugmmu,mungwall" }, +#else + { KRN_CmdLine, (IPTR)"nomonitors" }, +#endif + { KRN_KernelStackBase, (IPTR)&_ss }, + { KRN_KernelStackSize, (IPTR)(&_ss_end - &_ss) }, + { TAG_END }, }; struct TagItem *bootmsgptr = bootmsg; volatile APTR *trap; diff --git a/arch/m68k-amiga/c/mmakefile.src b/arch/m68k-amiga/c/mmakefile.src index 6c79b500a3..afe1039236 100644 --- a/arch/m68k-amiga/c/mmakefile.src +++ b/arch/m68k-amiga/c/mmakefile.src @@ -6,8 +6,7 @@ include $(SRCDIR)/config/aros.cfg USER_CPPFLAGS := -DADATE="\"$(shell date "+%d.%m.%Y")\"" USER_INCLUDES := -I$(GENINCDIR) -I$(SRCDIR) USER_CFLAGS := -fno-delete-null-pointer-checks -USER_AFLAGS := -Os -TARGET_ISA_AFLAGS:=$(ISA_MC68060_FLAGS) +USER_AFLAGS := -Os -march=68060 #MM- workbench-c-m68k : includes \ #MM kernel-kernel-includes \ diff --git a/arch/m68k-amiga/hidd/amigavideo/amigavideo.conf b/arch/m68k-amiga/hidd/amigavideo/amigavideo.conf index 09e582a05c..9858b7476e 100644 --- a/arch/m68k-amiga/hidd/amigavideo/amigavideo.conf +++ b/arch/m68k-amiga/hidd/amigavideo/amigavideo.conf @@ -2,7 +2,7 @@ basename AmigaVideoCl libbase AmigaVideoClBase libbasetype struct amigavideoclbase -version 45.1 +version 45.0 residentpri 9 classid CLID_Hidd_Gfx_AmigaVideo superclass CLID_Hidd_Gfx diff --git a/arch/m68k-amiga/hidd/amigavideo/amigavideo_bitmapclass.c b/arch/m68k-amiga/hidd/amigavideo/amigavideo_bitmapclass.c index 4bbc9d5780..76fa8e70f0 100644 --- a/arch/m68k-amiga/hidd/amigavideo/amigavideo_bitmapclass.c +++ b/arch/m68k-amiga/hidd/amigavideo/amigavideo_bitmapclass.c @@ -1,5 +1,5 @@ /* - Copyright 1995-2019, The AROS Development Team. All rights reserved. + Copyright 1995-2017, The AROS Development Team. All rights reserved. $Id$ Desc: Bitmap class for native Amiga chipset. @@ -25,8 +25,8 @@ #include #include -#define CMDDEBUGUNIMP(x) -#define CMDDEBUGPIXEL(x) +#define CMDDEBUGUNIMP(x) ; +#define CMDDEBUGPIXEL(x) ; #define DEBUG_TEXT(x) #include @@ -64,13 +64,13 @@ OOP_Object *AmigaVideoBM__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_N { TAG_END, 0 } }; - DB2(bug("[AmigaVideo:Bitmap] %s()\n", __func__)); + DB2(bug("AmigaVideoBM__Root__New\n")); mymsg.attrList = tags; o =(OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)&mymsg); if (NULL == o) - return NULL; - + return NULL; + data = OOP_INST_DATA(cl, o); memset(data, 0, sizeof (*data)); @@ -110,18 +110,14 @@ OOP_Object *AmigaVideoBM__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_N VOID AmigaVideoBM__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg) { struct amigabm_data *data; - + data = OOP_INST_DATA(cl, o); - - DB2( - bug("[AmigaVideo:Bitmap] %s(0x%p)\n", __func__, o); - bug("[AmigaVideo:Bitmap] %s: data @ 0x%p\n", __func__, data); - ) + + DB2(bug("AmigaVideoBM__Root__Dispose %x bm=%x\n", o, data)); if (data->disp) - { - DB2(bug("[AmigaVideo:Bitmap] %s: removing displayed bitmap?!\n", __func__);) - } - + DB2(bug("removing displayed bitmap?!\n")); + + OOP_DoSuperMethod(cl, o, msg); return; @@ -137,57 +133,49 @@ VOID AmigaVideoBM__Root__Set(OOP_Class *cl, OOP_Object *o, struct pRoot_Set *msg ULONG idx; BOOL moved = FALSE; - DB2(bug("[AmigaVideo:Bitmap] %s()\n", __func__)); + DB2(bug("AmigaVideoBM__Root__Set\n")); tstate = msg->attrList; while((tag = NextTagItem(&tstate))) { - DB2(bug("%d/%d\n", tag->ti_Tag, tag->ti_Data)); + DB2(bug("%d/%d\n", tag->ti_Tag, tag->ti_Data)); if(IS_BITMAP_ATTR(tag->ti_Tag, idx)) { DB2(bug("->%d\n", idx)); switch(idx) { - case aoHidd_BitMap_Focus: - { - volatile struct Custom *custom = (struct Custom*)0xdff000; - struct GfxBase *GfxBase = (struct GfxBase *)csd->cs_GfxBase; - D(bug("[AmigaVideo:Bitmap] %s: aoHidd_BitMap_Focus\n", __func__);) - custom->bplcon0 = GfxBase->system_bplcon0; - } - break; - case aoHidd_BitMap_Visible: - data->disp = tag->ti_Data; - if (data->disp) { - setrtg(csd, FALSE); - setbitmap(csd, data); - } else { - resetmode(csd); - setrtg(csd, TRUE); - } - break; - case aoHidd_BitMap_LeftEdge: - if (data->leftedge != tag->ti_Data) { - data->leftedge = tag->ti_Data; - moved = TRUE; - } - break; - case aoHidd_BitMap_TopEdge: - if (data->topedge != tag->ti_Data) { - data->topedge = tag->ti_Data; - if (data->topedge < 0) - data->topedge = 0; - if (data->topedge >= data->height) - data->topedge = data->height - 1; - moved = TRUE; - } - break; - } - } + case aoHidd_BitMap_Visible: + data->disp = tag->ti_Data; + if (data->disp) { + setrtg(csd, FALSE); + setbitmap(csd, data); + } else { + resetmode(csd); + setrtg(csd, TRUE); + } + break; + case aoHidd_BitMap_LeftEdge: + if (data->leftedge != tag->ti_Data) { + data->leftedge = tag->ti_Data; + moved = TRUE; + } + break; + case aoHidd_BitMap_TopEdge: + if (data->topedge != tag->ti_Data) { + data->topedge = tag->ti_Data; + if (data->topedge < 0) + data->topedge = 0; + if (data->topedge >= data->height) + data->topedge = data->height - 1; + moved = TRUE; + } + break; + } + } } DB2(bug("AmigaVideoBM__Root__Set Exit\n")); OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); if (moved && csd->disp == data) - setscroll(csd, data); + setscroll(csd, data); } VOID AmigaVideoBM__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg) @@ -199,40 +187,40 @@ VOID AmigaVideoBM__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg DB2(bug("AmigaVideoBM__Root__Get %d, Attr=%d AmigaVideoBitmap=%d\n", msg->attrID, __IHidd_Attr, __IHidd_BitMap_AmigaVideo)); if (IS_AmigaVideoBM_ATTR(msg->attrID, idx)) { - DB2(bug("AVBM=%d\n", idx)); - switch (idx) - { - case aoHidd_BitMap_AmigaVideo_Drawable: - *msg->storage = TRUE; - return; - } + DB2(bug("AVBM=%d\n", idx)); + switch (idx) + { + case aoHidd_BitMap_AmigaVideo_Drawable: + *msg->storage = TRUE; + return; + } } else if (IS_BITMAP_ATTR(msg->attrID, idx)) { - DB2(bug("BM=%d\n", idx)); - switch (idx) - { - case aoHidd_BitMap_LeftEdge: - *msg->storage = data->leftedge; - return; - case aoHidd_BitMap_TopEdge: - *msg->storage = data->topedge; - return; - case aoHidd_BitMap_Visible: - *msg->storage = data->disp; - return; - case aoHidd_BitMap_Align: - *msg->storage = csd->aga ? 64 : 16; - return; - case aoHidd_BitMap_BytesPerRow: - if (data->bytesperrow == 0) { - IPTR width = 0; - IPTR align = csd->aga ? 64 : 16; - OOP_GetAttr(o, aHidd_BitMap_Width, &width); - *msg->storage = ((width + align - 1) & ~(align - 1)) / 8; + DB2(bug("BM=%d\n", idx)); + switch (idx) + { + case aoHidd_BitMap_LeftEdge: + *msg->storage = data->leftedge; + return; + case aoHidd_BitMap_TopEdge: + *msg->storage = data->topedge; + return; + case aoHidd_BitMap_Visible: + *msg->storage = data->disp; + return; + case aoHidd_BitMap_Align: + *msg->storage = csd->aga ? 64 : 16; + return; + case aoHidd_BitMap_BytesPerRow: + if (data->bytesperrow == 0) { + IPTR width = 0; + IPTR align = csd->aga ? 64 : 16; + OOP_GetAttr(o, aHidd_BitMap_Width, &width); + *msg->storage = ((width + align - 1) & ~(align - 1)) / 8; } else { - *msg->storage = data->bytesperrow; + *msg->storage = data->bytesperrow; } - return; - } + return; + } } DB2(bug("AmigaVideoBM__Root__Get Exit\n")); OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); @@ -242,7 +230,7 @@ VOID AmigaVideoBM__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg static int AmigaVideoBM_Init(LIBBASETYPEPTR LIBBASE) { - D(bug("[AmigaVideo:Bitmap] %s()\n", __func__)); + D(bug("AmigaVideoBM_Init\n")); return TRUE; //return OOP_ObtainAttrBases(attrbases); } @@ -250,7 +238,7 @@ static int AmigaVideoBM_Init(LIBBASETYPEPTR LIBBASE) static int AmigaVideoBM_Expunge(LIBBASETYPEPTR LIBBASE) { - D(bug("[AmigaVideo:Bitmap] %s()\n", __func__)); + D(bug("AmigaVideoBM_Expunge\n")); //OOP_ReleaseAttrBases(attrbases); return TRUE; } @@ -268,7 +256,7 @@ BOOL AmigaVideoBM__Hidd_BitMap__SetColors(OOP_Class *cl, OOP_Object *o, struct p struct amigavideo_staticdata *csd = CSD(cl); if (!OOP_DoSuperMethod(cl, o, (OOP_Msg)msg)) - return FALSE; + return FALSE; return setcolors(csd, msg, data->disp); } @@ -284,46 +272,46 @@ static void flushpixelcache(struct amigabm_data *data) UBYTE **plane = bm->Planes; if (data->writemask) { - ULONG tmpplanes[8]; - ULONG pixel, notpixel, wmask; - if (~data->writemask) { - for (i = 0; i < bm->Depth; i++) { - if (plane[i] == (UBYTE*)-1) - tmpplanes[i] = 0xffffffff; - else if (plane[i] == NULL) - tmpplanes[i] = 0x00000000; - else - tmpplanes[i] = *((ULONG*)(plane[i] + offset)); - } - } - pixel = 0x80000000; - wmask = 1; - for (x = 0; pixel; x++, pixel >>= 1, wmask <<= 1) { - if (data->writemask & wmask) { - UBYTE c = data->pixelcache[x]; - UBYTE mask = 1; - notpixel = ~pixel; - for (i = 0; i < data->depth; i++, mask <<= 1) { - if (plane[i] != NULL && plane[i] != (UBYTE *)-1) { - if (c & mask) - tmpplanes[i] |= pixel; - else - tmpplanes[i] &= notpixel; - } - } - } - } - for (i = 0; i < data->depth; i++) { - if (plane[i] != NULL && plane[i] != (UBYTE *)-1) - *((ULONG*)(plane[i] + offset)) = tmpplanes[i]; - } + ULONG tmpplanes[8]; + ULONG pixel, notpixel, wmask; + if (~data->writemask) { + for (i = 0; i < bm->Depth; i++) { + if (plane[i] == (UBYTE*)-1) + tmpplanes[i] = 0xffffffff; + else if (plane[i] == NULL) + tmpplanes[i] = 0x00000000; + else + tmpplanes[i] = *((ULONG*)(plane[i] + offset)); + } + } + pixel = 0x80000000; + wmask = 1; + for (x = 0; pixel; x++, pixel >>= 1, wmask <<= 1) { + if (data->writemask & wmask) { + UBYTE c = data->pixelcache[x]; + UBYTE mask = 1; + notpixel = ~pixel; + for (i = 0; i < data->depth; i++, mask <<= 1) { + if (plane[i] != NULL && plane[i] != (UBYTE *)-1) { + if (c & mask) + tmpplanes[i] |= pixel; + else + tmpplanes[i] &= notpixel; + } + } + } + } + for (i = 0; i < data->depth; i++) { + if (plane[i] != NULL && plane[i] != (UBYTE *)-1) + *((ULONG*)(plane[i] + offset)) = tmpplanes[i]; + } } data->pixelcacheoffset = -1; data->writemask = 0; } VOID AmigaVideoBM__Hidd_BitMap__PutPixel(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_PutPixel *msg) + struct pHidd_BitMap_PutPixel *msg) { struct amigabm_data *data; ULONG offset; @@ -333,20 +321,20 @@ VOID AmigaVideoBM__Hidd_BitMap__PutPixel(OOP_Class *cl, OOP_Object *o, offset = msg->x / 8 + msg->y * data->bytesperrow; if ((offset & ~3) != data->pixelcacheoffset) { - CLEARCACHE; - data->pixelcacheoffset = offset & ~3; + CLEARCACHE; + data->pixelcacheoffset = offset & ~3; } bit = (offset - data->pixelcacheoffset) * 8 + (msg->x & 7); data->pixelcache[bit] = msg->pixel; data->writemask |= 1 << bit; - CMDDEBUGPIXEL(bug("PutPixel: %dx%d %x\n", msg->x, msg->y, msg->pixel);) + CMDDEBUGPIXEL(bug("PutPixel: %dx%d %x\n", msg->x, msg->y, msg->pixel)); } /****************************************************************************************/ ULONG AmigaVideoBM__Hidd_BitMap__GetPixel(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_GetPixel *msg) + struct pHidd_BitMap_GetPixel *msg) { struct amigabm_data *data; ULONG offset; @@ -356,40 +344,40 @@ ULONG AmigaVideoBM__Hidd_BitMap__GetPixel(OOP_Class *cl, OOP_Object *o, offset = msg->x / 8 + msg->y * data->bytesperrow; if ((offset & ~3) != data->pixelcacheoffset) { - ULONG tmpplanes[8], mask; - UBYTE x; - UBYTE **plane = data->pbm->Planes; + ULONG tmpplanes[8], mask; + UBYTE x; + UBYTE **plane = data->pbm->Planes; CLEARCACHE; - data->pixelcacheoffset = offset & ~3; - for (i = 0; i < data->depth; i++) { - if (plane[i] == (UBYTE*)-1) - tmpplanes[i] = 0xffffffff; - else if (plane[i] == NULL) - tmpplanes[i] = 0x00000000; - else - tmpplanes[i] = *((ULONG*)(plane[i] + data->pixelcacheoffset)); - } - mask = 0x80000000; - for (x = 0; mask; x++, mask >>= 1) { - UBYTE c = 0, pixel = 1; - for(i = 0; i < data->depth; i++, pixel <<= 1) { - if (tmpplanes[i] & mask) - c |= pixel; - } - data->pixelcache[x] = c; - } + data->pixelcacheoffset = offset & ~3; + for (i = 0; i < data->depth; i++) { + if (plane[i] == (UBYTE*)-1) + tmpplanes[i] = 0xffffffff; + else if (plane[i] == NULL) + tmpplanes[i] = 0x00000000; + else + tmpplanes[i] = *((ULONG*)(plane[i] + data->pixelcacheoffset)); + } + mask = 0x80000000; + for (x = 0; mask; x++, mask >>= 1) { + UBYTE c = 0, pixel = 1; + for(i = 0; i < data->depth; i++, pixel <<= 1) { + if (tmpplanes[i] & mask) + c |= pixel; + } + data->pixelcache[x] = c; + } } bit = (offset - data->pixelcacheoffset) * 8 + (msg->x & 7); c = data->pixelcache[bit]; - CMDDEBUGPIXEL(bug("GetPixel: %dx%d %x\n", msg->x, msg->y, c);) + CMDDEBUGPIXEL(bug("GetPixel: %dx%d %x\n", msg->x, msg->y, c)); return c; } /****************************************************************************************/ VOID AmigaVideoBM__Hidd_BitMap__DrawLine(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_DrawLine *msg) + struct pHidd_BitMap_DrawLine *msg) { OOP_Object *gc = msg->gc; HIDDT_Pixel fg = GC_FG(gc); @@ -459,34 +447,34 @@ VOID AmigaVideoBM__Hidd_BitMap__DrawLine(OOP_Class *cl, OOP_Object *o, OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); } else { OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - CMDDEBUGUNIMP(bug("[AmigaVideo:Bitmap] %s()\n", __func__);) + CMDDEBUGUNIMP(bug("DrawLine\n")); } } /****************************************************************************************/ VOID AmigaVideoBM__Hidd_BitMap__PutPattern(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_PutPattern *msg) + struct pHidd_BitMap_PutPattern *msg) { struct amigavideo_staticdata *csd = CSD(cl); struct amigabm_data *data = OOP_INST_DATA(cl, o); CLEARCACHE; D(bug("PutPattern(%dx%d,%dx%d,mask=%x,mod=%d,masksrcx=%d)\n(%x,%dx%d,h=%d,d=%d,lut=%x,inv=%d)(fg=%d,bg=%d,colexp=%d,drmd=%d)\n", - msg->x, msg->y, msg->width, msg->height, - msg->mask, msg->maskmodulo, msg->masksrcx, - msg->pattern, msg->patternsrcx, msg->patternsrcy, msg->patternheight, msg->patterndepth, msg->patternlut, msg->invertpattern, - GC_FG(msg->gc), GC_BG(msg->gc), GC_COLEXP(msg->gc), GC_DRMD(msg->gc))); + msg->x, msg->y, msg->width, msg->height, + msg->mask, msg->maskmodulo, msg->masksrcx, + msg->pattern, msg->patternsrcx, msg->patternsrcy, msg->patternheight, msg->patterndepth, msg->patternlut, msg->invertpattern, + GC_FG(msg->gc), GC_BG(msg->gc), GC_COLEXP(msg->gc), GC_DRMD(msg->gc))); if (!blit_putpattern(csd, data->pbm, msg)) - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); } /****************************************************************************************/ VOID AmigaVideoBM__Hidd_BitMap__PutImageLUT(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_PutImageLUT *msg) + struct pHidd_BitMap_PutImageLUT *msg) { WORD x, y, d; UBYTE *pixarray = (UBYTE *)msg->pixels; @@ -494,7 +482,7 @@ VOID AmigaVideoBM__Hidd_BitMap__PutImageLUT(OOP_Class *cl, OOP_Object *o, ULONG planeoffset; struct amigabm_data *data; - CMDDEBUGUNIMP(bug("[AmigaVideo:Bitmap] %s()\n", __func__);) + CMDDEBUGUNIMP(bug("PutImageLUT\n")); data = OOP_INST_DATA(cl, o); CLEARCACHE; @@ -503,58 +491,58 @@ VOID AmigaVideoBM__Hidd_BitMap__PutImageLUT(OOP_Class *cl, OOP_Object *o, for(y = 0; y < msg->height; y++) { - UBYTE *src = pixarray; - - plane = data->pbm->Planes; - - for(d = 0; d < data->depth; d++) - { - ULONG dmask = 1L << d; - ULONG pmask = 0x80 >> (msg->x & 7); - UBYTE *pl = *plane; - - if (pl == (UBYTE *)-1) continue; - if (pl == NULL) continue; - - pl += planeoffset; - - for(x = 0; x < msg->width; x++) - { - if (src[x] & dmask) - { - *pl |= pmask; - } - else - { - *pl &= ~pmask; - } - - if (pmask == 0x1) - { - pmask = 0x80; - pl++; - } - else - { - pmask >>= 1; - } - - } /* for(x = 0; x < msg->width; x++) */ - - plane++; - - } /* for(d = 0; d < data->depth; d++) */ - - pixarray += msg->modulo; - planeoffset += data->bytesperrow; - + UBYTE *src = pixarray; + + plane = data->pbm->Planes; + + for(d = 0; d < data->depth; d++) + { + ULONG dmask = 1L << d; + ULONG pmask = 0x80 >> (msg->x & 7); + UBYTE *pl = *plane; + + if (pl == (UBYTE *)-1) continue; + if (pl == NULL) continue; + + pl += planeoffset; + + for(x = 0; x < msg->width; x++) + { + if (src[x] & dmask) + { + *pl |= pmask; + } + else + { + *pl &= ~pmask; + } + + if (pmask == 0x1) + { + pmask = 0x80; + pl++; + } + else + { + pmask >>= 1; + } + + } /* for(x = 0; x < msg->width; x++) */ + + plane++; + + } /* for(d = 0; d < data->depth; d++) */ + + pixarray += msg->modulo; + planeoffset += data->bytesperrow; + } /* for(y = 0; y < msg->height; y++) */ } /****************************************************************************************/ VOID AmigaVideoBM__Hidd_BitMap__GetImageLUT(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_GetImageLUT *msg) + struct pHidd_BitMap_GetImageLUT *msg) { WORD x, y, d; UBYTE *pixarray = (UBYTE *)msg->pixels; @@ -565,81 +553,80 @@ VOID AmigaVideoBM__Hidd_BitMap__GetImageLUT(OOP_Class *cl, OOP_Object *o, data = OOP_INST_DATA(cl, o); - D(bug("[AmigaVideo:Bitmap] %s: Get %dx%d to %dx%d from %d planes to buffer at %p\n", - __func__, msg->x, msg->y, msg->x + msg->width - 1, msg->y + msg->height - 1, data->depth, msg->pixels)); + D(bug("[%s] Get %dx%d to %dx%d from %d planes to buffer at %p\n", __func__, msg->x, msg->y, msg->x + msg->width - 1, msg->y + msg->height - 1, data->depth, msg->pixels)); planeoffset = msg->y * data->bytesperrow + msg->x / 8; prefill = 0; for (d = 0; d < data->depth; d++) { - if (data->pbm->Planes[d] == (UBYTE *)-1) - { - prefill |= (1L << d); - } + if (data->pbm->Planes[d] == (UBYTE *)-1) + { + prefill |= (1L << d); + } } for (y = 0; y < msg->height; y++) { - UBYTE *dest = pixarray; - - plane = data->pbm->Planes; - for(x = 0; x < msg->width; x++) - { - dest[x] = prefill; - } - - for (d = 0; d < data->depth; d++) - { - ULONG dmask = 1L << d; - ULONG pmask = 0x80 >> (msg->x & 7); - UBYTE *pl = *plane; - - if (pl == (UBYTE *)-1) continue; - if (pl == NULL) continue; - - pl += planeoffset; - - for (x = 0; x < msg->width; x++) - { - if (*pl & pmask) - { - dest[x] |= dmask; - } - else - { - dest[x] &= ~dmask; - } - - if (pmask == 0x1) - { - pmask = 0x80; - pl++; - } - else - { - pmask >>= 1; - } - - } /* for(x = 0; x < msg->width; x++) */ - - plane++; - - } /* for(d = 0; d < data->depth; d++) */ - - pixarray += msg->modulo; - planeoffset += data->bytesperrow; - + UBYTE *dest = pixarray; + + plane = data->pbm->Planes; + for(x = 0; x < msg->width; x++) + { + dest[x] = prefill; + } + + for (d = 0; d < data->depth; d++) + { + ULONG dmask = 1L << d; + ULONG pmask = 0x80 >> (msg->x & 7); + UBYTE *pl = *plane; + + if (pl == (UBYTE *)-1) continue; + if (pl == NULL) continue; + + pl += planeoffset; + + for (x = 0; x < msg->width; x++) + { + if (*pl & pmask) + { + dest[x] |= dmask; + } + else + { + dest[x] &= ~dmask; + } + + if (pmask == 0x1) + { + pmask = 0x80; + pl++; + } + else + { + pmask >>= 1; + } + + } /* for(x = 0; x < msg->width; x++) */ + + plane++; + + } /* for(d = 0; d < data->depth; d++) */ + + pixarray += msg->modulo; + planeoffset += data->bytesperrow; + } /* for(y = 0; y < msg->height; y++) */ - D(bug("[AmigaVideo:Bitmap] %s: Got %d\n", __func__, *(UBYTE *)msg->pixels)); + D(bug("[%s] Got %d\n", __func__, *(UBYTE *)msg->pixels)); } /****************************************************************************************/ VOID AmigaVideoBM__Hidd_BitMap__PutImage(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_PutImage *msg) + struct pHidd_BitMap_PutImage *msg) { WORD x, y, d; UBYTE *pixarray = (UBYTE *)msg->pixels; @@ -650,120 +637,120 @@ VOID AmigaVideoBM__Hidd_BitMap__PutImage(OOP_Class *cl, OOP_Object *o, CLEARCACHE; if ((msg->pixFmt != vHidd_StdPixFmt_Native) && - (msg->pixFmt != vHidd_StdPixFmt_Native32)) + (msg->pixFmt != vHidd_StdPixFmt_Native32)) { - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - return; + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + return; } - CMDDEBUGUNIMP(bug("[AmigaVideo:Bitmap] %s()\n", __func__);) + CMDDEBUGUNIMP(bug("PutImage\n")); planeoffset = msg->y * data->bytesperrow + msg->x / 8; for(y = 0; y < msg->height; y++) { - switch(msg->pixFmt) - { - case vHidd_StdPixFmt_Native: - { - UBYTE *src = pixarray; - - plane = data->pbm->Planes; - - for(d = 0; d < data->depth; d++) - { - ULONG dmask = 1L << d; - ULONG pmask = 0x80 >> (msg->x & 7); - UBYTE *pl = *plane; - - if (pl == (UBYTE *)-1) continue; - if (pl == NULL) continue; - - pl += planeoffset; - - for(x = 0; x < msg->width; x++) - { - if (src[x] & dmask) - { - *pl |= pmask; - } - else - { - *pl &= ~pmask; - } - - if (pmask == 0x1) - { - pmask = 0x80; - pl++; - } - else - { - pmask >>= 1; - } - - } /* for(x = 0; x < msg->width; x++) */ - - plane++; - - } /* for(d = 0; d < data->depth; d++) */ - - pixarray += msg->modulo; - planeoffset += data->bytesperrow; - } - break; - - case vHidd_StdPixFmt_Native32: - { - HIDDT_Pixel *src = (HIDDT_Pixel *)pixarray; - - plane = data->pbm->Planes; - - for(d = 0; d < data->depth; d++) - { - ULONG dmask = 1L << d; - ULONG pmask = 0x80 >> (msg->x & 7); - UBYTE *pl = *plane; - - if (pl == (UBYTE *)-1) continue; - if (pl == NULL) continue; - - pl += planeoffset; - - for(x = 0; x < msg->width; x++) - { - if (src[x] & dmask) - { - *pl |= pmask; - } - else - { - *pl &= ~pmask; - } - - if (pmask == 0x1) - { - pmask = 0x80; - pl++; - } - else - { - pmask >>= 1; - } - - } /* for(x = 0; x < msg->width; x++) */ - - plane++; - - } /* for(d = 0; d < data->depth; d++) */ - - pixarray += msg->modulo; - planeoffset += data->bytesperrow; - } - - break; - - } /* switch(msg->pixFmt) */ - + switch(msg->pixFmt) + { + case vHidd_StdPixFmt_Native: + { + UBYTE *src = pixarray; + + plane = data->pbm->Planes; + + for(d = 0; d < data->depth; d++) + { + ULONG dmask = 1L << d; + ULONG pmask = 0x80 >> (msg->x & 7); + UBYTE *pl = *plane; + + if (pl == (UBYTE *)-1) continue; + if (pl == NULL) continue; + + pl += planeoffset; + + for(x = 0; x < msg->width; x++) + { + if (src[x] & dmask) + { + *pl |= pmask; + } + else + { + *pl &= ~pmask; + } + + if (pmask == 0x1) + { + pmask = 0x80; + pl++; + } + else + { + pmask >>= 1; + } + + } /* for(x = 0; x < msg->width; x++) */ + + plane++; + + } /* for(d = 0; d < data->depth; d++) */ + + pixarray += msg->modulo; + planeoffset += data->bytesperrow; + } + break; + + case vHidd_StdPixFmt_Native32: + { + HIDDT_Pixel *src = (HIDDT_Pixel *)pixarray; + + plane = data->pbm->Planes; + + for(d = 0; d < data->depth; d++) + { + ULONG dmask = 1L << d; + ULONG pmask = 0x80 >> (msg->x & 7); + UBYTE *pl = *plane; + + if (pl == (UBYTE *)-1) continue; + if (pl == NULL) continue; + + pl += planeoffset; + + for(x = 0; x < msg->width; x++) + { + if (src[x] & dmask) + { + *pl |= pmask; + } + else + { + *pl &= ~pmask; + } + + if (pmask == 0x1) + { + pmask = 0x80; + pl++; + } + else + { + pmask >>= 1; + } + + } /* for(x = 0; x < msg->width; x++) */ + + plane++; + + } /* for(d = 0; d < data->depth; d++) */ + + pixarray += msg->modulo; + planeoffset += data->bytesperrow; + } + + break; + + } /* switch(msg->pixFmt) */ + } /* for(y = 0; y < msg->height; y++) */ } @@ -778,8 +765,8 @@ VOID AmigaVideoBM__Hidd_BitMap__FillRect(OOP_Class *cl, OOP_Object *o, struct pH CLEARCACHE; if (!blit_fillrect(csd, data->pbm, msg->minX, msg->minY, msg->maxX, msg->maxY, fg, mode)) { - CMDDEBUGUNIMP(bug("[AmigaVideo:Bitmap] %s()\n", __func__);) - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + CMDDEBUGUNIMP(bug("FillRect\n")); + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); } } @@ -792,9 +779,9 @@ VOID AmigaVideoBM__Hidd_BitMap__PutTemplate(OOP_Class *cl, OOP_Object *o, struct CLEARCACHE; if (!blit_puttemplate(csd, data->pbm, msg)) { - CMDDEBUGUNIMP(bug("PutTemplate: %x x=%d y=%d w=%d h=%d srcx=%d modulo=%d invert=%d\n", - msg->masktemplate, msg->x, msg->y, msg->width, msg->height, msg->srcx, msg->inverttemplate);) - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + CMDDEBUGUNIMP(bug("PutTemplate: %x x=%d y=%d w=%d h=%d srcx=%d modulo=%d invert=%d\n", + msg->masktemplate, msg->x, msg->y, msg->width, msg->height, msg->srcx, msg->inverttemplate)); + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); } } @@ -808,17 +795,17 @@ VOID AmigaVideoBM__Hidd_BitMap__UpdateRect(OOP_Class *cl, OOP_Object *o, struct /****************************************************************************************/ BOOL AmigaVideoBM__Hidd_PlanarBM__SetBitMap(OOP_Class *cl, OOP_Object *o, - struct pHidd_PlanarBM_SetBitMap *msg) + struct pHidd_PlanarBM_SetBitMap *msg) { - CMDDEBUGUNIMP(bug("[AmigaVideo:Bitmap] %s()\n", __func__);) + CMDDEBUGUNIMP(bug("SetBitMap\n")); return OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); } /****************************************************************************************/ BOOL AmigaVideoBM__Hidd_PlanarBM__GetBitMap(OOP_Class *cl, OOP_Object *o, - struct pHidd_PlanarBM_GetBitMap *msg) + struct pHidd_PlanarBM_GetBitMap *msg) { - CMDDEBUGUNIMP(bug("[AmigaVideo:Bitmap] %s()\n", __func__);) + CMDDEBUGUNIMP(bug("GetBitMap\n")); return OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); } diff --git a/arch/m68k-amiga/hidd/amigavideo/amigavideo_hidd.h b/arch/m68k-amiga/hidd/amigavideo/amigavideo_hidd.h index 8c7ac765e0..d2d5ee5ffc 100644 --- a/arch/m68k-amiga/hidd/amigavideo/amigavideo_hidd.h +++ b/arch/m68k-amiga/hidd/amigavideo/amigavideo_hidd.h @@ -9,6 +9,17 @@ #include "amigavideo_intern.h" +#define __IHidd (csd->hiddAttrBase) +#define __IHidd_BitMap (csd->hiddBitMapAttrBase) +#define __IHidd_PlanarBM (csd->hiddPlanarBitMapAttrBase) +#define __IHidd_BitMap_AmigaVideo (csd->hiddAmigaVideoBitMapAttrBase) +#define __IHidd_GC (csd->hiddGCAttrBase) +#define __IHidd_Sync (csd->hiddSyncAttrBase) +#define __IHidd_PixFmt (csd->hiddPixFmtAttrBase) +#define __IHidd_Gfx (csd->hiddGfxAttrBase) +//#define __IHidd_Attr (csd->hiddAttrBase) +#define __IHidd_ColorMap (csd->hiddColorMapAttrBase) + struct copper2data { UWORD *copper2; @@ -117,17 +128,6 @@ struct amigavideoclbase #undef CSD #define CSD(cl) (&((struct amigavideoclbase *)cl->UserData)->csd) -#define __IHidd (csd->hiddAttrBase) -#define __IHidd_BitMap (csd->hiddBitMapAttrBase) -#define __IHidd_PlanarBM (csd->hiddPlanarBitMapAttrBase) -#define __IHidd_BitMap_AmigaVideo (csd->hiddAmigaVideoBitMapAttrBase) -#define __IHidd_GC (csd->hiddGCAttrBase) -#define __IHidd_Sync (csd->hiddSyncAttrBase) -#define __IHidd_PixFmt (csd->hiddPixFmtAttrBase) -#define __IHidd_Gfx (csd->hiddGfxAttrBase) -//#define __IHidd_Attr (csd->hiddAttrBase) -#define __IHidd_ColorMap (csd->hiddColorMapAttrBase) - /* Private instance data for Gfx hidd class */ struct amigagfx_data { diff --git a/arch/m68k-amiga/hidd/amigavideo/amigavideo_hiddclass.c b/arch/m68k-amiga/hidd/amigavideo/amigavideo_hiddclass.c dissimilarity index 61% index 272546f487..c93d1abc4c 100644 --- a/arch/m68k-amiga/hidd/amigavideo/amigavideo_hiddclass.c +++ b/arch/m68k-amiga/hidd/amigavideo/amigavideo_hiddclass.c @@ -1,949 +1,951 @@ -/* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. - $Id$ - - Desc: - Lang: English. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include LC_LIBDEFS_FILE - -#include "chipset.h" -#include "blitter.h" - -#include - -#define SPECIALMODES 3 -#define NATIVEMODES (3 * 4 * SPECIALMODES) -static const UWORD widthtable[] = { 320, 640, 1280, 0 }; -static const UWORD heighttable[] = { 200, 256, 400, 512, 0 }; -static const ULONG specialmask_aga[] = { 0, EXTRAHALFBRITE_KEY, HAM_KEY, 0xffffffff }; - -#define SPECIAL_MODE_MASK (EXTRAHALFBRITE_KEY | HAM_KEY) - -VOID AmigaVideoCl__Hidd_Gfx__NominalDimensions(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_NominalDimensions *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - struct GfxBase *GfxBase = (struct GfxBase *)csd->cs_GfxBase; - - DB2(bug("[AmigaVideo] %s()\n", __func__)); - - if (msg->width) - *(msg->width) = GfxBase->NormalDisplayColumns; - if (msg->height) - *(msg->height) = GfxBase->NormalDisplayRows; - if (msg->depth) - *(msg->depth) = 1; -} - -ULONG AmigaVideoCl__Hidd_Gfx__ModeProperties(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_ModeProperties *msg) -{ - ULONG flags = 0; - ULONG modeid = msg->modeID; - - flags = DIPF_IS_SPRITES | DIPF_IS_DRAGGABLE | - DIPF_IS_SPRITES_ATT | DIPF_IS_SPRITES_CHNG_BASE | DIPF_IS_SPRITES_CHNG_PRI | - DIPF_IS_DBUFFER | DIPF_IS_BEAMSYNC | DIPF_IS_GENLOCK; - msg->props->NumHWSprites = 8; - if ((modeid & MONITOR_ID_MASK) == PAL_MONITOR_ID) - flags |= DIPF_IS_PAL; - if (modeid & LORESLACE_KEY) - flags |= DIPF_IS_LACE; - if (modeid & HAM_KEY) { - flags |= DIPF_IS_HAM; - if (modeid & SUPER_KEY) - flags |= DIPF_IS_AA; - } - if (modeid & EXTRAHALFBRITE_KEY) { - flags |= DIPF_IS_EXTRAHALFBRITE; - if (modeid & SUPER_KEY) - flags |= DIPF_IS_AA; - } - if ((modeid & SUPER_KEY) == SUPER_KEY && !(flags & DIPF_IS_AA)) - flags |= DIPF_IS_ECS; - if (!(modeid & SPECIAL_MODE_MASK)) - flags |= DIPF_IS_WB; - msg->props->DisplayInfoFlags = flags; - msg->props->CompositionFlags = COMPF_ABOVE | COMPF_BELOW; // | COMPF_LEFT | COMPF_RIGHT; - DB2(bug("ModeProp %08x = %08x\n", modeid, flags)); - return sizeof(struct HIDD_ModeProperties); -} - -HIDDT_ModeID *AmigaVideoCl__Hidd_Gfx__QueryModeIDs(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_QueryModeIDs *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - struct NativeChipsetMode *node; - struct TagItem *tag, *tstate; - ULONG minwidth = 0, maxwidth = 0xFFFFFFFF; - ULONG minheight = 0, maxheight = 0xFFFFFFFF; - HIDDT_ModeID *modeids; - struct Library *UtilityBase = csd->cs_UtilityBase; - WORD cnt; - - if (csd->superforward) - return (HIDDT_ModeID*)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - - for (tstate = msg->queryTags; (tag = NextTagItem(&tstate)); ) - { - switch (tag->ti_Tag) - { - case tHidd_GfxMode_MinWidth: - minwidth = (ULONG)tag->ti_Tag; - break; - - case tHidd_GfxMode_MaxWidth: - maxwidth = (ULONG)tag->ti_Tag; - break; - - case tHidd_GfxMode_MinHeight: - minheight = (ULONG)tag->ti_Tag; - break; - - case tHidd_GfxMode_MaxHeight: - maxheight = (ULONG)tag->ti_Tag; - break; - - case tHidd_GfxMode_PixFmts: - /* all chipset modes have same pixelformat */ - break; - - } - } - DB2(bug("QueryModeIDs (%dx%d)-(%dx%d)\n", minwidth, minheight, maxwidth, maxheight)); - cnt = 0; - ForeachNode(&csd->nativemodelist, node) { - if (node->width >= minwidth && node->width <= maxwidth && node->height >= minheight && node->height <= maxheight) { - cnt++; - } - } - modeids = AllocVec((cnt + 1) * sizeof(HIDDT_ModeID), MEMF_PUBLIC); - if (!modeids) - return NULL; - cnt = 0; - ForeachNode(&csd->nativemodelist, node) { - if (node->width >= minwidth && node->width <= maxwidth && node->height >= minheight && node->height <= maxheight) { - DB2(bug("%d: %08x\n", cnt, node->modeid)); - modeids[cnt++] = node->modeid; - } - } - modeids[cnt] = vHidd_ModeID_Invalid; - return modeids; -} - -VOID AmigaVideoCl__Hidd_Gfx__ReleaseModeIDs(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_ReleaseModeIDs *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - if (csd->superforward) - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - else - FreeVec(msg->modeIDs); -} - -HIDDT_ModeID AmigaVideoCl__Hidd_Gfx__NextModeID(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_NextModeID *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - struct NativeChipsetMode *node = NULL; - HIDDT_ModeID mid = vHidd_ModeID_Invalid; - - DB2(bug("NextModeID %08x\n", msg->modeID)); - if (msg->modeID != vHidd_ModeID_Invalid) { - ForeachNode(&csd->nativemodelist, node) { - if (node->modeid == msg->modeID) { - node = (struct NativeChipsetMode*)node->node.ln_Succ; - break; - } - } - } - if (!node) - node = (struct NativeChipsetMode*)csd->nativemodelist.lh_Head; - if (node->node.ln_Succ) { - mid = node->modeid; - *msg->syncPtr = node->sync; - *msg->pixFmtPtr = node->pf; - } - DB2(bug("=%08x %p %p\n", mid, *msg->syncPtr, *msg->pixFmtPtr)); - return mid; -} - -BOOL AmigaVideoCl__Hidd_Gfx__GetMode(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_GetMode *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - struct NativeChipsetMode *node; - - if (csd->superforward) - return (BOOL)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - - DB2(bug("GetMode %08x\n", msg->modeID)); - ForeachNode(&csd->nativemodelist, node) { - if (node->modeid == msg->modeID) { - *msg->syncPtr = node->sync; - *msg->pixFmtPtr = node->pf; - DB2(bug("= %p %p %dx%dx%d %d\n", node->sync, node->pf, node->width, node->height, node->depth, node->special)); - return TRUE; - } - } - DB2(bug("= FAIL\n")); - return FALSE; -} - -#define ADDTAG(tag,data) { *tagptr++ = tag; *tagptr++ = data; } - - -static void makemodename(ULONG modeid, UBYTE *bufptr) -{ - BOOL special = FALSE; - - special = (modeid & SPECIAL_MODE_MASK) != 0; - bufptr[0] = 0; - if ((modeid & MONITOR_ID_MASK) == PAL_MONITOR_ID) - strcat(bufptr, "PAL"); - else if ((modeid & MONITOR_ID_MASK) == NTSC_MONITOR_ID) - strcat (bufptr, "NTSC"); - strcat(bufptr, ":"); - if ((modeid & (HIRES_KEY | SUPER_KEY)) == LORES_KEY) - strcat(bufptr, special ? "LowRes" : "Low Res"); - else if ((modeid & (HIRES_KEY | SUPER_KEY)) == HIRES_KEY) - strcat(bufptr, special ? "HighRes" : "High Res"); - else - strcat(bufptr, special ? "SuperHighRes" : "Super-High Res"); - if (modeid & HAM_KEY) - strcat(bufptr, " HAM"); - if (modeid & EXTRAHALFBRITE_KEY) - strcat(bufptr, " EHB"); - if ((modeid & LORESDPF2_KEY) == LORESDPF_KEY) - strcat(bufptr, " DualPF"); - if ((modeid & LORESDPF2_KEY) == LORESDPF2_KEY) - strcat(bufptr, " DualPF2"); - if (modeid & LORESLACE_KEY) - strcat(bufptr, special ? " Interlace" : " Laced"); - DB2(bug("%08x '%s'\n", modeid, bufptr)); -} - -static struct NativeChipsetMode *addmodeid(struct amigavideo_staticdata *csd, ULONG modeid, WORD w, WORD h, WORD d, UBYTE special) -{ - struct NativeChipsetMode *m; - - m = AllocMem(sizeof(struct NativeChipsetMode), MEMF_CLEAR | MEMF_PUBLIC); - DB2(bug("%p %08x %dx%dx%d %d\n", m, modeid, w, h, d, special)); - m->width = w; - m->height = h; - m->depth = d; - m->special = special; - m->modeid = modeid; - AddTail(&csd->nativemodelist, &m->node); - return m; -} - -/* this is SOOO HORRIBLE, do not even attempt to understand it.. */ - -OOP_Object *AmigaVideoCl__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - struct Library *OOPBase = csd->cs_OOPBase; - struct TagItem mytags[] = - { - { aHidd_Gfx_ModeTags , (IPTR)NULL }, - { aHidd_Name , (IPTR)"amigavideo.hidd" }, - { aHidd_HardwareName , (IPTR)"Amiga Native Display Hardware" }, - { aHidd_ProducerName , (IPTR)"Commodore International" }, - { TAG_MORE , (IPTR)msg->attrList } - }; - struct pRoot_New mymsg; - ULONG allocsize = 3000, allocsizebuf = 1000; - WORD x, y, cnt, i, j; - - UBYTE *buf, *bufptr; - ULONG *tags, *tagptr; - ULONG *modetags[NATIVEMODES], modeids[NATIVEMODES]; - ULONG *pftags_aga[SPECIALMODES]; - ULONG *pftags_ecs_shres = NULL, *pftags_ecs_hires, *pftags_ecs_lores, *pftags_ecs_6; - ULONG *mode_tags_aga; - ULONG *mode_tags_ecs; - - if (csd->initialized) - return NULL; - - NewList(&csd->nativemodelist); - tags = tagptr = AllocVec(allocsize, MEMF_PUBLIC | MEMF_REVERSE); - buf = bufptr = AllocVec(allocsizebuf, MEMF_PUBLIC | MEMF_REVERSE); - - cnt = 0; - for (y = 0; heighttable[y]; y++) { - WORD h = heighttable[y]; - for (x = 0; widthtable[x]; x++) { - WORD w = widthtable[x]; - WORD d, res; - ULONG modeid; - - modeid = 0; - if (w == 1280) { - res = 2; - modeid |= SUPER_KEY; - if (!csd->aga && !csd->ecs_denise) - continue; - d = csd->aga ? 8 : 2; - } - else if (w == 640) { - res = 1; - modeid |= HIRES_KEY; - d = csd->aga ? 8 : 4; - } else { - res = 0; - d = csd->aga ? 8 : 5; - } - if (h >= 400) - modeid |= LORESLACE_KEY; - if (h == 200 || h == 400) - modeid |= NTSC_MONITOR_ID; - else - modeid |= PAL_MONITOR_ID; - - for (i = 0; i < SPECIALMODES; i++) { - ULONG mid = modeid; - UWORD d2 = d; - if (i == 1) { - if (!csd->aga && (modeid & SUPER_KEY)) - continue; - mid |= EXTRAHALFBRITE_KEY; - d2 = 6; - } else if (i == 2) { - if (!csd->aga && (modeid & SUPER_KEY)) - continue; - mid |= HAM_KEY; - d2 = csd->aga ? 8 : 6; - } - - addmodeid(csd, mid, w, h, d2, csd->aga ? i : (i == 0 ? res : i - 1 + 3)); - modetags[cnt] = tagptr; - modeids[cnt++] = mid; - - ADDTAG(aHidd_Sync_HDisp, w); - ADDTAG(aHidd_Sync_VDisp, h); - ADDTAG(aHidd_Sync_Flags, h >= 400 ? vHidd_Sync_Interlaced : 0); - ADDTAG(aHidd_Sync_PixelClock, 1000000000 / (280 >> res)); - ADDTAG(TAG_DONE, 0); - } - - } - } - - if (csd->aga) { - - pftags_aga[0] = tagptr; - ADDTAG(aHidd_PixFmt_RedShift, 8); - ADDTAG(aHidd_PixFmt_GreenShift, 16); - ADDTAG(aHidd_PixFmt_BlueShift, 24); - ADDTAG(aHidd_PixFmt_AlphaShift, 0); - ADDTAG(aHidd_PixFmt_RedMask, 0x00FF0000); - ADDTAG(aHidd_PixFmt_GreenMask, 0x0000FF00); - ADDTAG(aHidd_PixFmt_BlueMask, 0x000000FF); - ADDTAG(aHidd_PixFmt_AlphaMask, 0x00000000); - ADDTAG(aHidd_PixFmt_CLUTMask, 0x000000FF); - ADDTAG(aHidd_PixFmt_CLUTShift, 0); - ADDTAG(aHidd_PixFmt_ColorModel, vHidd_ColorModel_Palette); - ADDTAG(aHidd_PixFmt_Depth, 8); - ADDTAG(aHidd_PixFmt_BytesPerPixel, 1); - ADDTAG(aHidd_PixFmt_BitsPerPixel, 8); - ADDTAG(aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Plane); - ADDTAG(aHidd_PixFmt_BitMapType, vHidd_BitMapType_Planar); - ADDTAG(TAG_DONE, 0); - - pftags_aga[1] = tagptr; - ADDTAG(aHidd_PixFmt_RedShift, 8); - ADDTAG(aHidd_PixFmt_GreenShift, 16); - ADDTAG(aHidd_PixFmt_BlueShift, 24); - ADDTAG(aHidd_PixFmt_AlphaShift, 0); - ADDTAG(aHidd_PixFmt_RedMask, 0x00FF0000); - ADDTAG(aHidd_PixFmt_GreenMask, 0x0000FF00); - ADDTAG(aHidd_PixFmt_BlueMask, 0x000000FF); - ADDTAG(aHidd_PixFmt_AlphaMask, 0x00000000); - ADDTAG(aHidd_PixFmt_CLUTMask, 0x000000FF); - ADDTAG(aHidd_PixFmt_CLUTShift, 0); - ADDTAG(aHidd_PixFmt_ColorModel, vHidd_ColorModel_Palette); - ADDTAG(aHidd_PixFmt_Depth, 6); - ADDTAG(aHidd_PixFmt_BytesPerPixel, 1); - ADDTAG(aHidd_PixFmt_BitsPerPixel, 6); - ADDTAG(aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Plane); - ADDTAG(aHidd_PixFmt_BitMapType, vHidd_BitMapType_Planar); - ADDTAG(TAG_DONE, 0); - - pftags_aga[2] = NULL; - - mode_tags_aga = tagptr; - ADDTAG(aHidd_Sync_HMin, 112); - ADDTAG(aHidd_Sync_VMin, 112); - ADDTAG(aHidd_Sync_HMax, 16384); - ADDTAG(aHidd_Sync_VMax, 16384); - - for (j = 0; specialmask_aga[j] != 0xffffffff; j++) { - if (pftags_aga[j]) - ADDTAG(aHidd_Gfx_PixFmtTags, (IPTR)pftags_aga[j]); - for (i = 0; i < cnt; i++) { - ULONG modeid = modeids[i]; - if ((j == 0 && !(modeid & SPECIAL_MODE_MASK)) || (j > 0 && ((modeid & SPECIAL_MODE_MASK) == specialmask_aga[j]))) { - makemodename(modeid, bufptr); - ADDTAG(aHidd_Sync_Description, (IPTR)bufptr); - bufptr += strlen(bufptr) + 1; - ADDTAG(aHidd_Gfx_SyncTags, (IPTR)modetags[i]); - } - } - } - - ADDTAG(TAG_DONE, 0); - - mytags[0].ti_Data = (IPTR)mode_tags_aga; - - } else { - - pftags_ecs_lores = tagptr; - ADDTAG(aHidd_PixFmt_RedShift, 20); - ADDTAG(aHidd_PixFmt_GreenShift, 24); - ADDTAG(aHidd_PixFmt_BlueShift, 28); - ADDTAG(aHidd_PixFmt_AlphaShift, 0); - ADDTAG(aHidd_PixFmt_RedMask, 0x00000F00); - ADDTAG(aHidd_PixFmt_GreenMask, 0x000000F0); - ADDTAG(aHidd_PixFmt_BlueMask, 0x0000000F); - ADDTAG(aHidd_PixFmt_AlphaMask, 0x00000000); - ADDTAG(aHidd_PixFmt_CLUTMask, 0x0000001F); - ADDTAG(aHidd_PixFmt_CLUTShift, 0); - ADDTAG(aHidd_PixFmt_ColorModel, vHidd_ColorModel_Palette); - ADDTAG(aHidd_PixFmt_Depth, 5); - ADDTAG(aHidd_PixFmt_BytesPerPixel, 1); - ADDTAG(aHidd_PixFmt_BitsPerPixel, 5); - ADDTAG(aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Plane); - ADDTAG(aHidd_PixFmt_BitMapType, vHidd_BitMapType_Planar); - ADDTAG(TAG_DONE, 0); - - pftags_ecs_hires = tagptr; - ADDTAG(aHidd_PixFmt_RedShift, 20); - ADDTAG(aHidd_PixFmt_GreenShift, 24); - ADDTAG(aHidd_PixFmt_BlueShift, 28); - ADDTAG(aHidd_PixFmt_AlphaShift, 0); - ADDTAG(aHidd_PixFmt_RedMask, 0x00000F00); - ADDTAG(aHidd_PixFmt_GreenMask, 0x000000F0); - ADDTAG(aHidd_PixFmt_BlueMask, 0x0000000F); - ADDTAG(aHidd_PixFmt_AlphaMask, 0x00000000); - ADDTAG(aHidd_PixFmt_CLUTMask, 0x0000001F); - ADDTAG(aHidd_PixFmt_CLUTShift, 0); - ADDTAG(aHidd_PixFmt_ColorModel, vHidd_ColorModel_Palette); - ADDTAG(aHidd_PixFmt_Depth, 4); - ADDTAG(aHidd_PixFmt_BytesPerPixel, 1); - ADDTAG(aHidd_PixFmt_BitsPerPixel, 4); - ADDTAG(aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Plane); - ADDTAG(aHidd_PixFmt_BitMapType, vHidd_BitMapType_Planar); - ADDTAG(TAG_DONE, 0); - - pftags_ecs_shres = tagptr; - ADDTAG(aHidd_PixFmt_RedShift, 20); - ADDTAG(aHidd_PixFmt_GreenShift, 24); - ADDTAG(aHidd_PixFmt_BlueShift, 28); - ADDTAG(aHidd_PixFmt_AlphaShift, 0); - ADDTAG(aHidd_PixFmt_RedMask, 0x00000F00); - ADDTAG(aHidd_PixFmt_GreenMask, 0x000000F0); - ADDTAG(aHidd_PixFmt_BlueMask, 0x0000000F); - ADDTAG(aHidd_PixFmt_AlphaMask, 0x00000000); - ADDTAG(aHidd_PixFmt_CLUTMask, 0x0000001F); - ADDTAG(aHidd_PixFmt_CLUTShift, 0); - ADDTAG(aHidd_PixFmt_ColorModel, vHidd_ColorModel_Palette); - ADDTAG(aHidd_PixFmt_Depth, 2); - ADDTAG(aHidd_PixFmt_BytesPerPixel, 1); - ADDTAG(aHidd_PixFmt_BitsPerPixel, 2); - ADDTAG(aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Plane); - ADDTAG(aHidd_PixFmt_BitMapType, vHidd_BitMapType_Planar); - ADDTAG(TAG_DONE, 0); - - pftags_ecs_6 = tagptr; - ADDTAG(aHidd_PixFmt_RedShift, 20); - ADDTAG(aHidd_PixFmt_GreenShift, 24); - ADDTAG(aHidd_PixFmt_BlueShift, 28); - ADDTAG(aHidd_PixFmt_AlphaShift, 0); - ADDTAG(aHidd_PixFmt_RedMask, 0x00000F00); - ADDTAG(aHidd_PixFmt_GreenMask, 0x000000F0); - ADDTAG(aHidd_PixFmt_BlueMask, 0x0000000F); - ADDTAG(aHidd_PixFmt_AlphaMask, 0x00000000); - ADDTAG(aHidd_PixFmt_CLUTMask, 0x0000001F); - ADDTAG(aHidd_PixFmt_CLUTShift, 0); - ADDTAG(aHidd_PixFmt_ColorModel, vHidd_ColorModel_Palette); - ADDTAG(aHidd_PixFmt_Depth, 6); - ADDTAG(aHidd_PixFmt_BytesPerPixel, 1); - ADDTAG(aHidd_PixFmt_BitsPerPixel, 6); - ADDTAG(aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Plane); - ADDTAG(aHidd_PixFmt_BitMapType, vHidd_BitMapType_Planar); - ADDTAG(TAG_DONE, 0); - - mode_tags_ecs = tagptr; - ADDTAG(aHidd_Sync_HMin, 112); - ADDTAG(aHidd_Sync_VMin, 112); - ADDTAG(aHidd_Sync_HMax, csd->ecs_agnus ? 16384 : 1008); - ADDTAG(aHidd_Sync_VMax, csd->ecs_agnus ? 16384 : 1008); - - ADDTAG(aHidd_Gfx_PixFmtTags, (IPTR)pftags_ecs_lores); - for (i = 0; i < cnt; i++) { - if ((modeids[i] & SPECIAL_MODE_MASK) || (modeids[i] & SUPER_KEY) != LORES_KEY) - continue; - makemodename(modeids[i], bufptr); - ADDTAG(aHidd_Sync_Description, (IPTR)bufptr); - bufptr += strlen(bufptr) + 1; - ADDTAG(aHidd_Gfx_SyncTags, (IPTR)modetags[i]); - } - - ADDTAG(aHidd_Gfx_PixFmtTags, (IPTR)pftags_ecs_hires); - for (i = 0; i < cnt; i++) { - if ((modeids[i] & SPECIAL_MODE_MASK) || (modeids[i] & SUPER_KEY) != HIRES_KEY) - continue; - makemodename(modeids[i], bufptr); - ADDTAG(aHidd_Sync_Description, (IPTR)bufptr); - bufptr += strlen(bufptr) + 1; - ADDTAG(aHidd_Gfx_SyncTags, (IPTR)modetags[i]); - } - - ADDTAG(aHidd_Gfx_PixFmtTags, (IPTR)pftags_ecs_shres); - if (csd->ecs_denise) { - for (i = 0; i < cnt; i++) { - if ((modeids[i] & SPECIAL_MODE_MASK) || (modeids[i] & SUPER_KEY) != SUPER_KEY) - continue; - makemodename(modeids[i], bufptr); - ADDTAG(aHidd_Sync_Description, (IPTR)bufptr); - bufptr += strlen(bufptr) + 1; - ADDTAG(aHidd_Gfx_SyncTags, (IPTR)modetags[i]); - } - } - - ADDTAG(aHidd_Gfx_PixFmtTags, (IPTR)pftags_ecs_6); - for (i = 0; i < cnt; i++) { - if (!(modeids[i] & SPECIAL_MODE_MASK)) - continue; - makemodename(modeids[i], bufptr); - ADDTAG(aHidd_Sync_Description, (IPTR)bufptr); - bufptr += strlen(bufptr) + 1; - ADDTAG(aHidd_Gfx_SyncTags, (IPTR)modetags[i]); - } - - ADDTAG(TAG_DONE, 0); - - mytags[0].ti_Data = (IPTR)mode_tags_ecs; - } - - D(bug("alloc=%d alloced=%d\n", allocsize, (ULONG)tagptr - (ULONG)tags)); - D(bug("allocbuf=%d allocedbuf=%d\n", allocsizebuf, bufptr - buf)); - - EnterFunc(bug("AGFX::New()\n")); - - mymsg.mID = msg->mID; - mymsg.attrList = mytags; - msg = &mymsg; - - /* Register gfxmodes */ - o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - if (NULL != o) - { - struct amigagfx_data *data = OOP_INST_DATA(cl, o); - struct NativeChipsetMode *node; - HIDDT_ModeID *midp; - UWORD pfcnt; - OOP_MethodID HiddGfxBase = csd->cs_HiddGfxBase; - OOP_Object *pixelformats[8] = { 0 }; - - D(bug("AGFX::New(): Got object from super\n")); - NewList((struct List *)&data->bitmaps); - csd->initialized = 1; - - /* this can't be the right way to match modes.. */ - csd->superforward = TRUE; - midp = HIDD_Gfx_QueryModeIDs(o, NULL); - for (pfcnt = 0, i = 0; midp[i] != vHidd_ModeID_Invalid; i++) { - OOP_Object *sync, *pf; - HIDDT_ModeID mid = midp[i]; - if (!HIDD_Gfx_GetMode(o, mid, &sync, &pf)) - continue; - for (j = 0; j < pfcnt; j++) { - if (pf == pixelformats[j]) - break; - } - if (j < pfcnt) - continue; - pixelformats[pfcnt++] = pf; - } - while (pfcnt < 8) { - if (csd->aga) - pixelformats[pfcnt] = pixelformats[0]; - else - pixelformats[pfcnt] = pixelformats[pfcnt - 1]; - pfcnt++; - } - for (i = 0; i < pfcnt; i++) { - DB2(bug("pf %d: %p\n", i, pixelformats[i])); - } - - ForeachNode(&csd->nativemodelist, node) { - if (!node->pf) { - OOP_Object *sync = NULL; - for (i = 0; midp[i] != vHidd_ModeID_Invalid; i++) { - HIDDT_ModeID mid = midp[i]; - IPTR dwidth, dheight; - OOP_Object *pf; - struct NativeChipsetMode *node2; - BOOL found = FALSE; - if (!HIDD_Gfx_GetMode(o, mid, &sync, &pf)) - continue; - OOP_GetAttr(sync, aHidd_Sync_HDisp, &dwidth); - OOP_GetAttr(sync, aHidd_Sync_VDisp, &dheight); - if (node->width != dwidth || node->height != dheight) - continue; - ForeachNode(&csd->nativemodelist, node2) { - if (node->width == dwidth && node->height == dheight) { - if (node2->sync == sync) { - found = TRUE; - break; - } - } - } - if (!found) - break; - } - if (midp[i] == vHidd_ModeID_Invalid) { - sync = NULL; - D(bug("sync not found!?\n")); - } - node->sync = sync; - node->pf = pixelformats[node->special]; - DB2(bug("%08x %dx%dx%d sync = %p pf = %p\n", - node->modeid, node->width, node->height, node->depth, node->sync, node->pf)); - } - } - HIDD_Gfx_ReleaseModeIDs(o, midp); - csd->superforward = FALSE; -#if 1 - ForeachNode(&csd->nativemodelist, node) { - DB2(bug("%08x %dx%dx%d sync = %p pf = %p\n", node->modeid, node->width, node->height, node->depth, node->sync, node->pf)); - } -#endif - - } - FreeVec(buf); - FreeVec(tags); - ReturnPtr("AGFX::New", OOP_Object *, o); -} - -/********** GfxHidd::Dispose() ******************************/ -VOID AmigaVideoCl__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg) -{ - EnterFunc(bug("AGFX::Dispose(o=%p)\n", o)); - - D(bug("AGFX::Dispose: calling super\n")); - OOP_DoSuperMethod(cl, o, msg); - - ReturnVoid("AGFX::Dispose"); -} - - -OOP_Object *AmigaVideoCl__Hidd_Gfx__CreateObject(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CreateObject *msg) -{ - OOP_Object *object = NULL; - - EnterFunc(bug("AGFX::CreateObject()\n")); - - if (msg->cl == CSD(cl)->cs_basebm) - { - struct amigavideo_staticdata *csd = CSD(cl); - struct Library *UtilityBase = csd->cs_UtilityBase; - HIDDT_ModeID modeid; - struct pHidd_Gfx_CreateObject p; - struct TagItem tags[] = - { - { TAG_IGNORE, TAG_IGNORE }, /* Placeholder for aHidd_BitMap_ClassPtr */ - { TAG_MORE, (IPTR)msg->attrList } - }; - - modeid = (HIDDT_ModeID)GetTagData(aHidd_BitMap_ModeID, vHidd_ModeID_Invalid, msg->attrList); - D(bug("modeid=%08x\n", modeid)); - if (modeid != vHidd_ModeID_Invalid) { - tags[0].ti_Tag = aHidd_BitMap_ClassPtr; - tags[0].ti_Data = (IPTR)CSD(cl)->amigabmclass; - - } - p.mID = msg->mID; - p.cl = msg->cl; - p.attrList = tags; - - object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)&p); - } - else - object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - - ReturnPtr("AGFX::CreateObject", OOP_Object *, object); -} - -VOID AmigaVideoCl__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - ULONG idx; - - //bug("AmigaVideoCl__Root__Get %x\n", msg->attrID); - - if (IS_GFX_ATTR(msg->attrID, idx)) - { - //bug("=%x\n", idx); - switch (idx) - { - case aoHidd_Gfx_HWSpriteTypes: - *msg->storage = vHidd_SpriteType_3Plus1; - return; - case aoHidd_Gfx_SupportsHWCursor: - case aoHidd_Gfx_NoFrameBuffer: - *msg->storage = TRUE; - return; - case aoHidd_Gfx_IsWindowed: - *msg->storage = FALSE; - return; - case aoHidd_Gfx_DriverName: - *msg->storage = (IPTR)"AmigaVideo"; - return; - } - } - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); -} - -VOID AmigaVideoCl__Root__Set(OOP_Class *cl, OOP_Object *obj, struct pRoot_Set *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - struct Library *UtilityBase = csd->cs_UtilityBase; - struct TagItem *tag, *tstate; - - tstate = msg->attrList; - while((tag = NextTagItem(&tstate))) - { - ULONG idx; - D(bug("AmigaVideoCl__Root__Set %x\n", tag->ti_Tag)); - if (IS_GFX_ATTR(tag->ti_Tag, idx)) { - D(bug("->%d\n", idx)); - switch(idx) - { - case aoHidd_Gfx_ActiveCallBack: - csd->acb = (void *)tag->ti_Data; - break; - - case aoHidd_Gfx_ActiveCallBackData: - csd->acbdata = (APTR)tag->ti_Data; - break; - } - } - } - OOP_DoSuperMethod(cl, obj, (OOP_Msg)msg); -} - -ULONG AmigaVideoCl__Hidd_Gfx__ShowViewPorts(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_ShowViewPorts *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - struct Library *OOPBase = csd->cs_OOPBase; - struct HIDD_ViewPortData *vpd = msg->Data; - OOP_Object *bm = NULL; - - if (vpd) - bm = vpd->Bitmap; - - D(bug("AmigaShowViewPorts %p %p\n", vpd, bm)); - - if (bm) { - struct amigabm_data *data = OOP_INST_DATA(OOP_OCLASS(bm), bm); - IPTR tags[] = {aHidd_BitMap_Visible, TRUE, TAG_DONE}; - IPTR modeid = vHidd_ModeID_Invalid; - - OOP_GetAttr(bm, aHidd_BitMap_ModeID , &modeid); - csd->modeid = modeid; - setmode(csd, data); - OOP_SetAttrs(bm, (struct TagItem *)tags); - - if (csd->acb) - csd->acb(csd->acbdata, bm); - - } else { - resetmode(csd); - } - - return TRUE; -} - -VOID AmigaVideoCl__Hidd_Gfx__CopyBox(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CopyBox *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - struct Library *OOPBase = csd->cs_OOPBase; - HIDDT_DrawMode mode = GC_DRMD(msg->gc); - IPTR src, dst; - BOOL ok = FALSE; - - OOP_GetAttr(msg->src, aHidd_BitMap_AmigaVideo_Drawable, &src); - OOP_GetAttr(msg->dest, aHidd_BitMap_AmigaVideo_Drawable, &dst); - if (src && dst) { - struct amigabm_data *sdata = OOP_INST_DATA(OOP_OCLASS(msg->src), msg->src); - struct amigabm_data *ddata = OOP_INST_DATA(OOP_OCLASS(msg->dest), msg->dest); - ok = blit_copybox(csd, sdata->pbm, ddata->pbm, msg->srcX, msg->srcY, msg->width, msg->height, msg->destX, msg->destY, mode); - } - if (!ok) - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); -} - -BOOL AmigaVideoCl__Hidd_Gfx__CopyBoxMasked(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CopyBoxMasked *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - struct Library *OOPBase = csd->cs_OOPBase; - HIDDT_DrawMode mode = GC_DRMD(msg->gc); - IPTR src, dst; - BOOL ok = FALSE; - - OOP_GetAttr(msg->src, aHidd_BitMap_AmigaVideo_Drawable, &src); - OOP_GetAttr(msg->dest, aHidd_BitMap_AmigaVideo_Drawable, &dst); - if (src && dst) { - struct amigabm_data *sdata = OOP_INST_DATA(OOP_OCLASS(msg->src), msg->src); - struct amigabm_data *ddata = OOP_INST_DATA(OOP_OCLASS(msg->dest), msg->dest); - ok = blit_copybox_mask(csd, sdata->pbm, ddata->pbm, msg->srcX, msg->srcY, msg->width, msg->height, msg->destX, msg->destY, mode, msg->mask); - } - if (!ok) - return OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - - return TRUE; -} - -BOOL AmigaVideoCl__Hidd_Gfx__SetCursorShape(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorShape *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - struct Library *OOPBase = csd->cs_OOPBase; - IPTR width, height; - UWORD maxw, maxh; - - OOP_GetAttr(msg->shape, aHidd_BitMap_Width, &width); - OOP_GetAttr(msg->shape, aHidd_BitMap_Height, &height); - - maxw = (csd->aga ? 64 : 16); - maxh = maxw * 2; - - if (width > maxw || height > maxh) - return FALSE; - - return setsprite(cl, o, width, height, msg); -} - -BOOL AmigaVideoCl__Hidd_Gfx__GetMaxSpriteSize(OOP_Class *cl, ULONG Type, ULONG *Width, ULONG *Height) -{ - struct amigavideo_staticdata *csd = CSD(cl); - *Width = csd->aga ? 64 : 16; - *Height = *Width * 2; - return TRUE; -} -BOOL AmigaVideoCl__Hidd_Gfx__SetCursorPos(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorPos *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - setspritepos(csd, msg->x, msg->y); - return TRUE; -} -VOID AmigaVideoCl__Hidd_Gfx__SetCursorVisible(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorVisible *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - setspritevisible(csd, msg->visible); -} - -ULONG AmigaVideoCl__Hidd_Gfx__MakeViewPort(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_MakeViewPort *msg) -{ - D(struct HIDD_ViewPortData *vpd = msg->Data); - - D(bug("AmigaVideoCl__Hidd_Gfx__MakeViewPort vp=%p bm=%p vpe=%p\n", vpd->vpe->ViewPort, vpd->Bitmap, vpd->vpe)); - /* TODO: implement this correctly */ - return MVP_OK; -} - -void AmigaVideoCl__Hidd_Gfx__CleanViewPort(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CleanViewPort *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - struct Library *GfxBase = csd->cs_GfxBase; - struct HIDD_ViewPortData *vpd = msg->Data; - struct ViewPort *vp = vpd->vpe->ViewPort; - - D(bug("AmigaVideoCl__Hidd_Gfx__CleanViewPort vp=%p bm=%p vpe=%p\n", vpd->vpe->ViewPort, vpd->Bitmap, vpd->vpe)); - /* It's safe to call these functions on NULL pointers */ - FreeCopList(vp->ClrIns); - FreeCopList(vp->DspIns); - FreeCopList(vp->SprIns); - - if (vp->UCopIns) - { - FreeCopList(vp->UCopIns->FirstCopList); - FreeMem(vp->UCopIns, sizeof(struct UCopList)); - } - - /* Everything has been freed */ - vp->ClrIns = NULL; - vp->DspIns = NULL; - vp->SprIns = NULL; - vp->UCopIns = NULL; -} - -static void freeattrbases(struct amigavideo_staticdata *csd) -{ - struct Library *OOPBase = csd->cs_OOPBase; - - OOP_ReleaseAttrBase(IID_Hidd); - OOP_ReleaseAttrBase(IID_Hidd_BitMap); - OOP_ReleaseAttrBase(IID_Hidd_PlanarBM); - OOP_ReleaseAttrBase(IID_Hidd_BitMap_AmigaVideo); - OOP_ReleaseAttrBase(IID_Hidd_GC); - OOP_ReleaseAttrBase(IID_Hidd_Sync); - OOP_ReleaseAttrBase(IID_Hidd_Gfx); - OOP_ReleaseAttrBase(IID_Hidd_PixFmt); - OOP_ReleaseAttrBase(IID_Hidd_ColorMap); -} - -int Init_AmigaVideoClass(LIBBASETYPEPTR LIBBASE) -{ - struct amigavideo_staticdata *csd = &LIBBASE->csd; - struct Library *OOPBase = csd->cs_OOPBase; - - D(bug("Init_AmigaVideoClass\n")); - __IHidd = OOP_ObtainAttrBase(IID_Hidd); - __IHidd_BitMap = OOP_ObtainAttrBase(IID_Hidd_BitMap); - __IHidd_PlanarBM = OOP_ObtainAttrBase(IID_Hidd_PlanarBM); - __IHidd_BitMap_AmigaVideo = OOP_ObtainAttrBase(IID_Hidd_BitMap_AmigaVideo); - __IHidd_GC = OOP_ObtainAttrBase(IID_Hidd_GC); - __IHidd_Sync = OOP_ObtainAttrBase(IID_Hidd_Sync); - __IHidd_Gfx = OOP_ObtainAttrBase(IID_Hidd_Gfx); - __IHidd_PixFmt = OOP_ObtainAttrBase(IID_Hidd_PixFmt); - __IHidd_ColorMap = OOP_ObtainAttrBase(IID_Hidd_ColorMap); - - if (!__IHidd || !__IHidd_BitMap || !__IHidd_PlanarBM || !__IHidd_BitMap_AmigaVideo || - !__IHidd_GC || !__IHidd_Sync || !__IHidd_Gfx || !__IHidd_PixFmt || !__IHidd_ColorMap) - { - D(bug("Init_AmigaVideoClass fail\n")); - freeattrbases(csd); - return 0; - } - return TRUE; -} - - -static int Expunge_AmigaVideoClass(LIBBASETYPEPTR LIBBASE) -{ - struct amigavideo_staticdata *csd = &LIBBASE->csd; - D(bug("Expunge_AmigaVideoClass\n")); - freeattrbases(csd); - return TRUE; -} - -ADD2EXPUNGELIB(Expunge_AmigaVideoClass, 1) +/* + Copyright © 1995-2017, The AROS Development Team. All rights reserved. + $Id$ + + Desc: + Lang: English. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include LC_LIBDEFS_FILE + +#include "chipset.h" +#include "blitter.h" + +#define SDEBUG 0 +#define DEBUG 0 +#include + +#define SPECIALMODES 3 +#define NATIVEMODES (3 * 4 * SPECIALMODES) +static const UWORD widthtable[] = { 320, 640, 1280, 0 }; +static const UWORD heighttable[] = { 200, 256, 400, 512, 0 }; +static const ULONG specialmask_aga[] = { 0, EXTRAHALFBRITE_KEY, HAM_KEY, 0xffffffff }; + +#define SPECIAL_MODE_MASK (EXTRAHALFBRITE_KEY | HAM_KEY) + +VOID AmigaVideoCl__Hidd_Gfx__NominalDimensions(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_NominalDimensions *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + struct GfxBase *GfxBase = (struct GfxBase *)csd->cs_GfxBase; + + DB2(bug("NominalDimensions()\n")); + + if (msg->width) + *(msg->width) = GfxBase->NormalDisplayColumns; + if (msg->height) + *(msg->height) = GfxBase->NormalDisplayRows; + if (msg->depth) + *(msg->depth) = 1; +} + +ULONG AmigaVideoCl__Hidd_Gfx__ModeProperties(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_ModeProperties *msg) +{ + ULONG flags = 0; + ULONG modeid = msg->modeID; + + flags = DIPF_IS_SPRITES | DIPF_IS_DRAGGABLE | + DIPF_IS_SPRITES_ATT | DIPF_IS_SPRITES_CHNG_BASE | DIPF_IS_SPRITES_CHNG_PRI | + DIPF_IS_DBUFFER | DIPF_IS_BEAMSYNC | DIPF_IS_GENLOCK; + msg->props->NumHWSprites = 8; + if ((modeid & MONITOR_ID_MASK) == PAL_MONITOR_ID) + flags |= DIPF_IS_PAL; + if (modeid & LORESLACE_KEY) + flags |= DIPF_IS_LACE; + if (modeid & HAM_KEY) { + flags |= DIPF_IS_HAM; + if (modeid & SUPER_KEY) + flags |= DIPF_IS_AA; + } + if (modeid & EXTRAHALFBRITE_KEY) { + flags |= DIPF_IS_EXTRAHALFBRITE; + if (modeid & SUPER_KEY) + flags |= DIPF_IS_AA; + } + if ((modeid & SUPER_KEY) == SUPER_KEY && !(flags & DIPF_IS_AA)) + flags |= DIPF_IS_ECS; + if (!(modeid & SPECIAL_MODE_MASK)) + flags |= DIPF_IS_WB; + msg->props->DisplayInfoFlags = flags; + msg->props->CompositionFlags = COMPF_ABOVE | COMPF_BELOW; // | COMPF_LEFT | COMPF_RIGHT; + DB2(bug("ModeProp %08x = %08x\n", modeid, flags)); + return sizeof(struct HIDD_ModeProperties); +} + +HIDDT_ModeID *AmigaVideoCl__Hidd_Gfx__QueryModeIDs(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_QueryModeIDs *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + struct NativeChipsetMode *node; + struct TagItem *tag, *tstate; + ULONG minwidth = 0, maxwidth = 0xFFFFFFFF; + ULONG minheight = 0, maxheight = 0xFFFFFFFF; + HIDDT_ModeID *modeids; + struct Library *UtilityBase = csd->cs_UtilityBase; + WORD cnt; + + if (csd->superforward) + return (HIDDT_ModeID*)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + + for (tstate = msg->queryTags; (tag = NextTagItem(&tstate)); ) + { + switch (tag->ti_Tag) + { + case tHidd_GfxMode_MinWidth: + minwidth = (ULONG)tag->ti_Tag; + break; + + case tHidd_GfxMode_MaxWidth: + maxwidth = (ULONG)tag->ti_Tag; + break; + + case tHidd_GfxMode_MinHeight: + minheight = (ULONG)tag->ti_Tag; + break; + + case tHidd_GfxMode_MaxHeight: + maxheight = (ULONG)tag->ti_Tag; + break; + + case tHidd_GfxMode_PixFmts: + /* all chipset modes have same pixelformat */ + break; + + } + } + DB2(bug("QueryModeIDs (%dx%d)-(%dx%d)\n", minwidth, minheight, maxwidth, maxheight)); + cnt = 0; + ForeachNode(&csd->nativemodelist, node) { + if (node->width >= minwidth && node->width <= maxwidth && node->height >= minheight && node->height <= maxheight) { + cnt++; + } + } + modeids = AllocVec((cnt + 1) * sizeof(HIDDT_ModeID), MEMF_PUBLIC); + if (!modeids) + return NULL; + cnt = 0; + ForeachNode(&csd->nativemodelist, node) { + if (node->width >= minwidth && node->width <= maxwidth && node->height >= minheight && node->height <= maxheight) { + DB2(bug("%d: %08x\n", cnt, node->modeid)); + modeids[cnt++] = node->modeid; + } + } + modeids[cnt] = vHidd_ModeID_Invalid; + return modeids; +} + +VOID AmigaVideoCl__Hidd_Gfx__ReleaseModeIDs(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_ReleaseModeIDs *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + if (csd->superforward) + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + else + FreeVec(msg->modeIDs); +} + +HIDDT_ModeID AmigaVideoCl__Hidd_Gfx__NextModeID(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_NextModeID *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + struct NativeChipsetMode *node = NULL; + HIDDT_ModeID mid = vHidd_ModeID_Invalid; + + DB2(bug("NextModeID %08x\n", msg->modeID)); + if (msg->modeID != vHidd_ModeID_Invalid) { + ForeachNode(&csd->nativemodelist, node) { + if (node->modeid == msg->modeID) { + node = (struct NativeChipsetMode*)node->node.ln_Succ; + break; + } + } + } + if (!node) + node = (struct NativeChipsetMode*)csd->nativemodelist.lh_Head; + if (node->node.ln_Succ) { + mid = node->modeid; + *msg->syncPtr = node->sync; + *msg->pixFmtPtr = node->pf; + } + DB2(bug("=%08x %p %p\n", mid, *msg->syncPtr, *msg->pixFmtPtr)); + return mid; +} + +BOOL AmigaVideoCl__Hidd_Gfx__GetMode(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_GetMode *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + struct NativeChipsetMode *node; + + if (csd->superforward) + return (BOOL)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + + DB2(bug("GetMode %08x\n", msg->modeID)); + ForeachNode(&csd->nativemodelist, node) { + if (node->modeid == msg->modeID) { + *msg->syncPtr = node->sync; + *msg->pixFmtPtr = node->pf; + DB2(bug("= %p %p %dx%dx%d %d\n", node->sync, node->pf, node->width, node->height, node->depth, node->special)); + return TRUE; + } + } + DB2(bug("= FAIL\n")); + return FALSE; +} + +#define ADDTAG(tag,data) { *tagptr++ = tag; *tagptr++ = data; } + + +static void makemodename(ULONG modeid, UBYTE *bufptr) +{ + BOOL special = FALSE; + + special = (modeid & SPECIAL_MODE_MASK) != 0; + bufptr[0] = 0; + if ((modeid & MONITOR_ID_MASK) == PAL_MONITOR_ID) + strcat(bufptr, "PAL"); + else if ((modeid & MONITOR_ID_MASK) == NTSC_MONITOR_ID) + strcat (bufptr, "NTSC"); + strcat(bufptr, ":"); + if ((modeid & (HIRES_KEY | SUPER_KEY)) == LORES_KEY) + strcat(bufptr, special ? "LowRes" : "Low Res"); + else if ((modeid & (HIRES_KEY | SUPER_KEY)) == HIRES_KEY) + strcat(bufptr, special ? "HighRes" : "High Res"); + else + strcat(bufptr, special ? "SuperHighRes" : "Super-High Res"); + if (modeid & HAM_KEY) + strcat(bufptr, " HAM"); + if (modeid & EXTRAHALFBRITE_KEY) + strcat(bufptr, " EHB"); + if ((modeid & LORESDPF2_KEY) == LORESDPF_KEY) + strcat(bufptr, " DualPF"); + if ((modeid & LORESDPF2_KEY) == LORESDPF2_KEY) + strcat(bufptr, " DualPF2"); + if (modeid & LORESLACE_KEY) + strcat(bufptr, special ? " Interlace" : " Laced"); + DB2(bug("%08x '%s'\n", modeid, bufptr)); +} + +static struct NativeChipsetMode *addmodeid(struct amigavideo_staticdata *csd, ULONG modeid, WORD w, WORD h, WORD d, UBYTE special) +{ + struct NativeChipsetMode *m; + + m = AllocMem(sizeof(struct NativeChipsetMode), MEMF_CLEAR | MEMF_PUBLIC); + DB2(bug("%p %08x %dx%dx%d %d\n", m, modeid, w, h, d, special)); + m->width = w; + m->height = h; + m->depth = d; + m->special = special; + m->modeid = modeid; + AddTail(&csd->nativemodelist, &m->node); + return m; +} + +/* this is SOOO HORRIBLE, do not even attempt to understand it.. */ + +OOP_Object *AmigaVideoCl__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + struct Library *OOPBase = csd->cs_OOPBase; + struct TagItem mytags[] = + { + { aHidd_Gfx_ModeTags , (IPTR)NULL }, + { aHidd_Name , (IPTR)"amigavideo.hidd" }, + { aHidd_HardwareName , (IPTR)"Amiga Native Display Hardware" }, + { aHidd_ProducerName , (IPTR)"Commodore International" }, + { TAG_MORE , (IPTR)msg->attrList } + }; + struct pRoot_New mymsg; + ULONG allocsize = 3000, allocsizebuf = 1000; + WORD x, y, cnt, i, j; + + UBYTE *buf, *bufptr; + ULONG *tags, *tagptr; + ULONG *modetags[NATIVEMODES], modeids[NATIVEMODES]; + ULONG *pftags_aga[SPECIALMODES]; + ULONG *pftags_ecs_shres = NULL, *pftags_ecs_hires, *pftags_ecs_lores, *pftags_ecs_6; + ULONG *mode_tags_aga; + ULONG *mode_tags_ecs; + + if (csd->initialized) + return NULL; + + NewList(&csd->nativemodelist); + tags = tagptr = AllocVec(allocsize, MEMF_PUBLIC | MEMF_REVERSE); + buf = bufptr = AllocVec(allocsizebuf, MEMF_PUBLIC | MEMF_REVERSE); + + cnt = 0; + for (y = 0; heighttable[y]; y++) { + WORD h = heighttable[y]; + for (x = 0; widthtable[x]; x++) { + WORD w = widthtable[x]; + WORD d, res; + ULONG modeid; + + modeid = 0; + if (w == 1280) { + res = 2; + modeid |= SUPER_KEY; + if (!csd->aga && !csd->ecs_denise) + continue; + d = csd->aga ? 8 : 2; + } + else if (w == 640) { + res = 1; + modeid |= HIRES_KEY; + d = csd->aga ? 8 : 4; + } else { + res = 0; + d = csd->aga ? 8 : 5; + } + if (h >= 400) + modeid |= LORESLACE_KEY; + if (h == 200 || h == 400) + modeid |= NTSC_MONITOR_ID; + else + modeid |= PAL_MONITOR_ID; + + for (i = 0; i < SPECIALMODES; i++) { + ULONG mid = modeid; + UWORD d2 = d; + if (i == 1) { + if (!csd->aga && (modeid & SUPER_KEY)) + continue; + mid |= EXTRAHALFBRITE_KEY; + d2 = 6; + } else if (i == 2) { + if (!csd->aga && (modeid & SUPER_KEY)) + continue; + mid |= HAM_KEY; + d2 = csd->aga ? 8 : 6; + } + + addmodeid(csd, mid, w, h, d2, csd->aga ? i : (i == 0 ? res : i - 1 + 3)); + modetags[cnt] = tagptr; + modeids[cnt++] = mid; + + ADDTAG(aHidd_Sync_HDisp, w); + ADDTAG(aHidd_Sync_VDisp, h); + ADDTAG(aHidd_Sync_Flags, h >= 400 ? vHidd_Sync_Interlaced : 0); + ADDTAG(aHidd_Sync_PixelClock, 1000000000 / (280 >> res)); + ADDTAG(TAG_DONE, 0); + } + + } + } + + if (csd->aga) { + + pftags_aga[0] = tagptr; + ADDTAG(aHidd_PixFmt_RedShift, 8); + ADDTAG(aHidd_PixFmt_GreenShift, 16); + ADDTAG(aHidd_PixFmt_BlueShift, 24); + ADDTAG(aHidd_PixFmt_AlphaShift, 0); + ADDTAG(aHidd_PixFmt_RedMask, 0x00FF0000); + ADDTAG(aHidd_PixFmt_GreenMask, 0x0000FF00); + ADDTAG(aHidd_PixFmt_BlueMask, 0x000000FF); + ADDTAG(aHidd_PixFmt_AlphaMask, 0x00000000); + ADDTAG(aHidd_PixFmt_CLUTMask, 0x000000FF); + ADDTAG(aHidd_PixFmt_CLUTShift, 0); + ADDTAG(aHidd_PixFmt_ColorModel, vHidd_ColorModel_Palette); + ADDTAG(aHidd_PixFmt_Depth, 8); + ADDTAG(aHidd_PixFmt_BytesPerPixel, 1); + ADDTAG(aHidd_PixFmt_BitsPerPixel, 8); + ADDTAG(aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Plane); + ADDTAG(aHidd_PixFmt_BitMapType, vHidd_BitMapType_Planar); + ADDTAG(TAG_DONE, 0); + + pftags_aga[1] = tagptr; + ADDTAG(aHidd_PixFmt_RedShift, 8); + ADDTAG(aHidd_PixFmt_GreenShift, 16); + ADDTAG(aHidd_PixFmt_BlueShift, 24); + ADDTAG(aHidd_PixFmt_AlphaShift, 0); + ADDTAG(aHidd_PixFmt_RedMask, 0x00FF0000); + ADDTAG(aHidd_PixFmt_GreenMask, 0x0000FF00); + ADDTAG(aHidd_PixFmt_BlueMask, 0x000000FF); + ADDTAG(aHidd_PixFmt_AlphaMask, 0x00000000); + ADDTAG(aHidd_PixFmt_CLUTMask, 0x000000FF); + ADDTAG(aHidd_PixFmt_CLUTShift, 0); + ADDTAG(aHidd_PixFmt_ColorModel, vHidd_ColorModel_Palette); + ADDTAG(aHidd_PixFmt_Depth, 6); + ADDTAG(aHidd_PixFmt_BytesPerPixel, 1); + ADDTAG(aHidd_PixFmt_BitsPerPixel, 6); + ADDTAG(aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Plane); + ADDTAG(aHidd_PixFmt_BitMapType, vHidd_BitMapType_Planar); + ADDTAG(TAG_DONE, 0); + + pftags_aga[2] = NULL; + + mode_tags_aga = tagptr; + ADDTAG(aHidd_Sync_HMin, 112); + ADDTAG(aHidd_Sync_VMin, 112); + ADDTAG(aHidd_Sync_HMax, 16384); + ADDTAG(aHidd_Sync_VMax, 16384); + + for (j = 0; specialmask_aga[j] != 0xffffffff; j++) { + if (pftags_aga[j]) + ADDTAG(aHidd_Gfx_PixFmtTags, (IPTR)pftags_aga[j]); + for (i = 0; i < cnt; i++) { + ULONG modeid = modeids[i]; + if ((j == 0 && !(modeid & SPECIAL_MODE_MASK)) || (j > 0 && ((modeid & SPECIAL_MODE_MASK) == specialmask_aga[j]))) { + makemodename(modeid, bufptr); + ADDTAG(aHidd_Sync_Description, (IPTR)bufptr); + bufptr += strlen(bufptr) + 1; + ADDTAG(aHidd_Gfx_SyncTags, (IPTR)modetags[i]); + } + } + } + + ADDTAG(TAG_DONE, 0); + + mytags[0].ti_Data = (IPTR)mode_tags_aga; + + } else { + + pftags_ecs_lores = tagptr; + ADDTAG(aHidd_PixFmt_RedShift, 20); + ADDTAG(aHidd_PixFmt_GreenShift, 24); + ADDTAG(aHidd_PixFmt_BlueShift, 28); + ADDTAG(aHidd_PixFmt_AlphaShift, 0); + ADDTAG(aHidd_PixFmt_RedMask, 0x00000F00); + ADDTAG(aHidd_PixFmt_GreenMask, 0x000000F0); + ADDTAG(aHidd_PixFmt_BlueMask, 0x0000000F); + ADDTAG(aHidd_PixFmt_AlphaMask, 0x00000000); + ADDTAG(aHidd_PixFmt_CLUTMask, 0x0000001F); + ADDTAG(aHidd_PixFmt_CLUTShift, 0); + ADDTAG(aHidd_PixFmt_ColorModel, vHidd_ColorModel_Palette); + ADDTAG(aHidd_PixFmt_Depth, 5); + ADDTAG(aHidd_PixFmt_BytesPerPixel, 1); + ADDTAG(aHidd_PixFmt_BitsPerPixel, 5); + ADDTAG(aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Plane); + ADDTAG(aHidd_PixFmt_BitMapType, vHidd_BitMapType_Planar); + ADDTAG(TAG_DONE, 0); + + pftags_ecs_hires = tagptr; + ADDTAG(aHidd_PixFmt_RedShift, 20); + ADDTAG(aHidd_PixFmt_GreenShift, 24); + ADDTAG(aHidd_PixFmt_BlueShift, 28); + ADDTAG(aHidd_PixFmt_AlphaShift, 0); + ADDTAG(aHidd_PixFmt_RedMask, 0x00000F00); + ADDTAG(aHidd_PixFmt_GreenMask, 0x000000F0); + ADDTAG(aHidd_PixFmt_BlueMask, 0x0000000F); + ADDTAG(aHidd_PixFmt_AlphaMask, 0x00000000); + ADDTAG(aHidd_PixFmt_CLUTMask, 0x0000001F); + ADDTAG(aHidd_PixFmt_CLUTShift, 0); + ADDTAG(aHidd_PixFmt_ColorModel, vHidd_ColorModel_Palette); + ADDTAG(aHidd_PixFmt_Depth, 4); + ADDTAG(aHidd_PixFmt_BytesPerPixel, 1); + ADDTAG(aHidd_PixFmt_BitsPerPixel, 4); + ADDTAG(aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Plane); + ADDTAG(aHidd_PixFmt_BitMapType, vHidd_BitMapType_Planar); + ADDTAG(TAG_DONE, 0); + + pftags_ecs_shres = tagptr; + ADDTAG(aHidd_PixFmt_RedShift, 20); + ADDTAG(aHidd_PixFmt_GreenShift, 24); + ADDTAG(aHidd_PixFmt_BlueShift, 28); + ADDTAG(aHidd_PixFmt_AlphaShift, 0); + ADDTAG(aHidd_PixFmt_RedMask, 0x00000F00); + ADDTAG(aHidd_PixFmt_GreenMask, 0x000000F0); + ADDTAG(aHidd_PixFmt_BlueMask, 0x0000000F); + ADDTAG(aHidd_PixFmt_AlphaMask, 0x00000000); + ADDTAG(aHidd_PixFmt_CLUTMask, 0x0000001F); + ADDTAG(aHidd_PixFmt_CLUTShift, 0); + ADDTAG(aHidd_PixFmt_ColorModel, vHidd_ColorModel_Palette); + ADDTAG(aHidd_PixFmt_Depth, 2); + ADDTAG(aHidd_PixFmt_BytesPerPixel, 1); + ADDTAG(aHidd_PixFmt_BitsPerPixel, 2); + ADDTAG(aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Plane); + ADDTAG(aHidd_PixFmt_BitMapType, vHidd_BitMapType_Planar); + ADDTAG(TAG_DONE, 0); + + pftags_ecs_6 = tagptr; + ADDTAG(aHidd_PixFmt_RedShift, 20); + ADDTAG(aHidd_PixFmt_GreenShift, 24); + ADDTAG(aHidd_PixFmt_BlueShift, 28); + ADDTAG(aHidd_PixFmt_AlphaShift, 0); + ADDTAG(aHidd_PixFmt_RedMask, 0x00000F00); + ADDTAG(aHidd_PixFmt_GreenMask, 0x000000F0); + ADDTAG(aHidd_PixFmt_BlueMask, 0x0000000F); + ADDTAG(aHidd_PixFmt_AlphaMask, 0x00000000); + ADDTAG(aHidd_PixFmt_CLUTMask, 0x0000001F); + ADDTAG(aHidd_PixFmt_CLUTShift, 0); + ADDTAG(aHidd_PixFmt_ColorModel, vHidd_ColorModel_Palette); + ADDTAG(aHidd_PixFmt_Depth, 6); + ADDTAG(aHidd_PixFmt_BytesPerPixel, 1); + ADDTAG(aHidd_PixFmt_BitsPerPixel, 6); + ADDTAG(aHidd_PixFmt_StdPixFmt, vHidd_StdPixFmt_Plane); + ADDTAG(aHidd_PixFmt_BitMapType, vHidd_BitMapType_Planar); + ADDTAG(TAG_DONE, 0); + + mode_tags_ecs = tagptr; + ADDTAG(aHidd_Sync_HMin, 112); + ADDTAG(aHidd_Sync_VMin, 112); + ADDTAG(aHidd_Sync_HMax, csd->ecs_agnus ? 16384 : 1008); + ADDTAG(aHidd_Sync_VMax, csd->ecs_agnus ? 16384 : 1008); + + ADDTAG(aHidd_Gfx_PixFmtTags, (IPTR)pftags_ecs_lores); + for (i = 0; i < cnt; i++) { + if ((modeids[i] & SPECIAL_MODE_MASK) || (modeids[i] & SUPER_KEY) != LORES_KEY) + continue; + makemodename(modeids[i], bufptr); + ADDTAG(aHidd_Sync_Description, (IPTR)bufptr); + bufptr += strlen(bufptr) + 1; + ADDTAG(aHidd_Gfx_SyncTags, (IPTR)modetags[i]); + } + + ADDTAG(aHidd_Gfx_PixFmtTags, (IPTR)pftags_ecs_hires); + for (i = 0; i < cnt; i++) { + if ((modeids[i] & SPECIAL_MODE_MASK) || (modeids[i] & SUPER_KEY) != HIRES_KEY) + continue; + makemodename(modeids[i], bufptr); + ADDTAG(aHidd_Sync_Description, (IPTR)bufptr); + bufptr += strlen(bufptr) + 1; + ADDTAG(aHidd_Gfx_SyncTags, (IPTR)modetags[i]); + } + + ADDTAG(aHidd_Gfx_PixFmtTags, (IPTR)pftags_ecs_shres); + if (csd->ecs_denise) { + for (i = 0; i < cnt; i++) { + if ((modeids[i] & SPECIAL_MODE_MASK) || (modeids[i] & SUPER_KEY) != SUPER_KEY) + continue; + makemodename(modeids[i], bufptr); + ADDTAG(aHidd_Sync_Description, (IPTR)bufptr); + bufptr += strlen(bufptr) + 1; + ADDTAG(aHidd_Gfx_SyncTags, (IPTR)modetags[i]); + } + } + + ADDTAG(aHidd_Gfx_PixFmtTags, (IPTR)pftags_ecs_6); + for (i = 0; i < cnt; i++) { + if (!(modeids[i] & SPECIAL_MODE_MASK)) + continue; + makemodename(modeids[i], bufptr); + ADDTAG(aHidd_Sync_Description, (IPTR)bufptr); + bufptr += strlen(bufptr) + 1; + ADDTAG(aHidd_Gfx_SyncTags, (IPTR)modetags[i]); + } + + ADDTAG(TAG_DONE, 0); + + mytags[0].ti_Data = (IPTR)mode_tags_ecs; + } + + D(bug("alloc=%d alloced=%d\n", allocsize, (ULONG)tagptr - (ULONG)tags)); + D(bug("allocbuf=%d allocedbuf=%d\n", allocsizebuf, bufptr - buf)); + + EnterFunc(bug("AGFX::New()\n")); + + mymsg.mID = msg->mID; + mymsg.attrList = mytags; + msg = &mymsg; + + /* Register gfxmodes */ + o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + if (NULL != o) + { + struct amigagfx_data *data = OOP_INST_DATA(cl, o); + struct NativeChipsetMode *node; + HIDDT_ModeID *midp; + UWORD pfcnt; + OOP_MethodID HiddGfxBase = csd->cs_HiddGfxBase; + OOP_Object *pixelformats[8] = { 0 }; + + D(bug("AGFX::New(): Got object from super\n")); + NewList((struct List *)&data->bitmaps); + csd->initialized = 1; + + /* this can't be the right way to match modes.. */ + csd->superforward = TRUE; + midp = HIDD_Gfx_QueryModeIDs(o, NULL); + for (pfcnt = 0, i = 0; midp[i] != vHidd_ModeID_Invalid; i++) { + OOP_Object *sync, *pf; + HIDDT_ModeID mid = midp[i]; + if (!HIDD_Gfx_GetMode(o, mid, &sync, &pf)) + continue; + for (j = 0; j < pfcnt; j++) { + if (pf == pixelformats[j]) + break; + } + if (j < pfcnt) + continue; + pixelformats[pfcnt++] = pf; + } + while (pfcnt < 8) { + if (csd->aga) + pixelformats[pfcnt] = pixelformats[0]; + else + pixelformats[pfcnt] = pixelformats[pfcnt - 1]; + pfcnt++; + } + for (i = 0; i < pfcnt; i++) { + DB2(bug("pf %d: %p\n", i, pixelformats[i])); + } + + ForeachNode(&csd->nativemodelist, node) { + if (!node->pf) { + OOP_Object *sync = NULL; + for (i = 0; midp[i] != vHidd_ModeID_Invalid; i++) { + HIDDT_ModeID mid = midp[i]; + IPTR dwidth, dheight; + OOP_Object *pf; + struct NativeChipsetMode *node2; + BOOL found = FALSE; + if (!HIDD_Gfx_GetMode(o, mid, &sync, &pf)) + continue; + OOP_GetAttr(sync, aHidd_Sync_HDisp, &dwidth); + OOP_GetAttr(sync, aHidd_Sync_VDisp, &dheight); + if (node->width != dwidth || node->height != dheight) + continue; + ForeachNode(&csd->nativemodelist, node2) { + if (node->width == dwidth && node->height == dheight) { + if (node2->sync == sync) { + found = TRUE; + break; + } + } + } + if (!found) + break; + } + if (midp[i] == vHidd_ModeID_Invalid) { + sync = NULL; + D(bug("sync not found!?\n")); + } + node->sync = sync; + node->pf = pixelformats[node->special]; + DB2(bug("%08x %dx%dx%d sync = %p pf = %p\n", + node->modeid, node->width, node->height, node->depth, node->sync, node->pf)); + } + } + HIDD_Gfx_ReleaseModeIDs(o, midp); + csd->superforward = FALSE; +#if 1 + ForeachNode(&csd->nativemodelist, node) { + DB2(bug("%08x %dx%dx%d sync = %p pf = %p\n", node->modeid, node->width, node->height, node->depth, node->sync, node->pf)); + } +#endif + + } + FreeVec(buf); + FreeVec(tags); + ReturnPtr("AGFX::New", OOP_Object *, o); +} + +/********** GfxHidd::Dispose() ******************************/ +VOID AmigaVideoCl__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg) +{ + EnterFunc(bug("AGFX::Dispose(o=%p)\n", o)); + + D(bug("AGFX::Dispose: calling super\n")); + OOP_DoSuperMethod(cl, o, msg); + + ReturnVoid("AGFX::Dispose"); +} + + +OOP_Object *AmigaVideoCl__Hidd_Gfx__CreateObject(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CreateObject *msg) +{ + OOP_Object *object = NULL; + + EnterFunc(bug("AGFX::CreateObject()\n")); + + if (msg->cl == CSD(cl)->cs_basebm) + { + struct amigavideo_staticdata *csd = CSD(cl); + struct Library *UtilityBase = csd->cs_UtilityBase; + HIDDT_ModeID modeid; + struct pHidd_Gfx_CreateObject p; + struct TagItem tags[] = + { + { TAG_IGNORE, TAG_IGNORE }, /* Placeholder for aHidd_BitMap_ClassPtr */ + { TAG_MORE, (IPTR)msg->attrList } + }; + + modeid = (HIDDT_ModeID)GetTagData(aHidd_BitMap_ModeID, vHidd_ModeID_Invalid, msg->attrList); + D(bug("modeid=%08x\n", modeid)); + if (modeid != vHidd_ModeID_Invalid) { + tags[0].ti_Tag = aHidd_BitMap_ClassPtr; + tags[0].ti_Data = (IPTR)CSD(cl)->amigabmclass; + + } + p.mID = msg->mID; + p.cl = msg->cl; + p.attrList = tags; + + object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)&p); + } + else + object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + + ReturnPtr("AGFX::CreateObject", OOP_Object *, object); +} + +VOID AmigaVideoCl__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + ULONG idx; + + //bug("AmigaVideoCl__Root__Get %x\n", msg->attrID); + + if (IS_GFX_ATTR(msg->attrID, idx)) + { + //bug("=%x\n", idx); + switch (idx) + { + case aoHidd_Gfx_HWSpriteTypes: + *msg->storage = vHidd_SpriteType_3Plus1; + return; + case aoHidd_Gfx_SupportsHWCursor: + case aoHidd_Gfx_NoFrameBuffer: + *msg->storage = TRUE; + return; + case aoHidd_Gfx_IsWindowed: + *msg->storage = FALSE; + return; + case aoHidd_Gfx_DriverName: + *msg->storage = (IPTR)"AmigaVideo"; + return; + } + } + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); +} + +VOID AmigaVideoCl__Root__Set(OOP_Class *cl, OOP_Object *obj, struct pRoot_Set *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + struct Library *UtilityBase = csd->cs_UtilityBase; + struct TagItem *tag, *tstate; + + tstate = msg->attrList; + while((tag = NextTagItem(&tstate))) + { + ULONG idx; + D(bug("AmigaVideoCl__Root__Set %x\n", tag->ti_Tag)); + if (IS_GFX_ATTR(tag->ti_Tag, idx)) { + D(bug("->%d\n", idx)); + switch(idx) + { + case aoHidd_Gfx_ActiveCallBack: + csd->acb = (void *)tag->ti_Data; + break; + + case aoHidd_Gfx_ActiveCallBackData: + csd->acbdata = (APTR)tag->ti_Data; + break; + } + } + } + OOP_DoSuperMethod(cl, obj, (OOP_Msg)msg); +} + +ULONG AmigaVideoCl__Hidd_Gfx__ShowViewPorts(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_ShowViewPorts *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + struct Library *OOPBase = csd->cs_OOPBase; + struct HIDD_ViewPortData *vpd = msg->Data; + OOP_Object *bm = NULL; + + if (vpd) + bm = vpd->Bitmap; + + D(bug("AmigaShowViewPorts %p %p\n", vpd, bm)); + + if (bm) { + struct amigabm_data *data = OOP_INST_DATA(OOP_OCLASS(bm), bm); + IPTR tags[] = {aHidd_BitMap_Visible, TRUE, TAG_DONE}; + IPTR modeid = vHidd_ModeID_Invalid; + + OOP_GetAttr(bm, aHidd_BitMap_ModeID , &modeid); + csd->modeid = modeid; + setmode(csd, data); + OOP_SetAttrs(bm, (struct TagItem *)tags); + + if (csd->acb) + csd->acb(csd->acbdata, NULL); + + } else { + resetmode(csd); + } + + return TRUE; +} + +VOID AmigaVideoCl__Hidd_Gfx__CopyBox(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CopyBox *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + struct Library *OOPBase = csd->cs_OOPBase; + HIDDT_DrawMode mode = GC_DRMD(msg->gc); + IPTR src, dst; + BOOL ok = FALSE; + + OOP_GetAttr(msg->src, aHidd_BitMap_AmigaVideo_Drawable, &src); + OOP_GetAttr(msg->dest, aHidd_BitMap_AmigaVideo_Drawable, &dst); + if (src && dst) { + struct amigabm_data *sdata = OOP_INST_DATA(OOP_OCLASS(msg->src), msg->src); + struct amigabm_data *ddata = OOP_INST_DATA(OOP_OCLASS(msg->dest), msg->dest); + ok = blit_copybox(csd, sdata->pbm, ddata->pbm, msg->srcX, msg->srcY, msg->width, msg->height, msg->destX, msg->destY, mode); + } + if (!ok) + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); +} + +BOOL AmigaVideoCl__Hidd_Gfx__CopyBoxMasked(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CopyBoxMasked *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + struct Library *OOPBase = csd->cs_OOPBase; + HIDDT_DrawMode mode = GC_DRMD(msg->gc); + IPTR src, dst; + BOOL ok = FALSE; + + OOP_GetAttr(msg->src, aHidd_BitMap_AmigaVideo_Drawable, &src); + OOP_GetAttr(msg->dest, aHidd_BitMap_AmigaVideo_Drawable, &dst); + if (src && dst) { + struct amigabm_data *sdata = OOP_INST_DATA(OOP_OCLASS(msg->src), msg->src); + struct amigabm_data *ddata = OOP_INST_DATA(OOP_OCLASS(msg->dest), msg->dest); + ok = blit_copybox_mask(csd, sdata->pbm, ddata->pbm, msg->srcX, msg->srcY, msg->width, msg->height, msg->destX, msg->destY, mode, msg->mask); + } + if (!ok) + return OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + + return TRUE; +} + +BOOL AmigaVideoCl__Hidd_Gfx__SetCursorShape(OOP_Class *cl, OOP_Object *shape, struct pHidd_Gfx_SetCursorShape *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + struct Library *OOPBase = csd->cs_OOPBase; + IPTR width, height; + UWORD maxw, maxh; + + OOP_GetAttr(msg->shape, aHidd_BitMap_Width, &width); + OOP_GetAttr(msg->shape, aHidd_BitMap_Height, &height); + + maxw = (csd->aga ? 64 : 16); + maxh = maxw * 2; + + if (width > maxw || height > maxh) + return FALSE; + + return setsprite(csd, width, height, msg); +} + +BOOL AmigaVideoCl__Hidd_Gfx__GetMaxSpriteSize(OOP_Class *cl, ULONG Type, ULONG *Width, ULONG *Height) +{ + struct amigavideo_staticdata *csd = CSD(cl); + *Width = csd->aga ? 64 : 16; + *Height = *Width * 2; + return TRUE; +} +BOOL AmigaVideoCl__Hidd_Gfx__SetCursorPos(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorPos *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + setspritepos(csd, msg->x, msg->y); + return TRUE; +} +VOID AmigaVideoCl__Hidd_Gfx__SetCursorVisible(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorVisible *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + setspritevisible(csd, msg->visible); +} + +ULONG AmigaVideoCl__Hidd_Gfx__MakeViewPort(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_MakeViewPort *msg) +{ + D(struct HIDD_ViewPortData *vpd = msg->Data); + + D(bug("AmigaVideoCl__Hidd_Gfx__MakeViewPort vp=%p bm=%p vpe=%p\n", vpd->vpe->ViewPort, vpd->Bitmap, vpd->vpe)); + /* TODO: implement this correctly */ + return MVP_OK; +} + +void AmigaVideoCl__Hidd_Gfx__CleanViewPort(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CleanViewPort *msg) +{ + struct amigavideo_staticdata *csd = CSD(cl); + struct Library *GfxBase = csd->cs_GfxBase; + struct HIDD_ViewPortData *vpd = msg->Data; + struct ViewPort *vp = vpd->vpe->ViewPort; + + D(bug("AmigaVideoCl__Hidd_Gfx__CleanViewPort vp=%p bm=%p vpe=%p\n", vpd->vpe->ViewPort, vpd->Bitmap, vpd->vpe)); + /* It's safe to call these functions on NULL pointers */ + FreeCopList(vp->ClrIns); + FreeCopList(vp->DspIns); + FreeCopList(vp->SprIns); + + if (vp->UCopIns) + { + FreeCopList(vp->UCopIns->FirstCopList); + FreeMem(vp->UCopIns, sizeof(struct UCopList)); + } + + /* Everything has been freed */ + vp->ClrIns = NULL; + vp->DspIns = NULL; + vp->SprIns = NULL; + vp->UCopIns = NULL; +} + +static void freeattrbases(struct amigavideo_staticdata *csd) +{ + struct Library *OOPBase = csd->cs_OOPBase; + + OOP_ReleaseAttrBase(IID_Hidd); + OOP_ReleaseAttrBase(IID_Hidd_BitMap); + OOP_ReleaseAttrBase(IID_Hidd_PlanarBM); + OOP_ReleaseAttrBase(IID_Hidd_BitMap_AmigaVideo); + OOP_ReleaseAttrBase(IID_Hidd_GC); + OOP_ReleaseAttrBase(IID_Hidd_Sync); + OOP_ReleaseAttrBase(IID_Hidd_Gfx); + OOP_ReleaseAttrBase(IID_Hidd_PixFmt); + OOP_ReleaseAttrBase(IID_Hidd_ColorMap); +} + +int Init_AmigaVideoClass(LIBBASETYPEPTR LIBBASE) +{ + struct amigavideo_staticdata *csd = &LIBBASE->csd; + struct Library *OOPBase = csd->cs_OOPBase; + + D(bug("Init_AmigaVideoClass\n")); + __IHidd = OOP_ObtainAttrBase(IID_Hidd); + __IHidd_BitMap = OOP_ObtainAttrBase(IID_Hidd_BitMap); + __IHidd_PlanarBM = OOP_ObtainAttrBase(IID_Hidd_PlanarBM); + __IHidd_BitMap_AmigaVideo = OOP_ObtainAttrBase(IID_Hidd_BitMap_AmigaVideo); + __IHidd_GC = OOP_ObtainAttrBase(IID_Hidd_GC); + __IHidd_Sync = OOP_ObtainAttrBase(IID_Hidd_Sync); + __IHidd_Gfx = OOP_ObtainAttrBase(IID_Hidd_Gfx); + __IHidd_PixFmt = OOP_ObtainAttrBase(IID_Hidd_PixFmt); + __IHidd_ColorMap = OOP_ObtainAttrBase(IID_Hidd_ColorMap); + + if (!__IHidd || !__IHidd_BitMap || !__IHidd_PlanarBM || !__IHidd_BitMap_AmigaVideo || + !__IHidd_GC || !__IHidd_Sync || !__IHidd_Gfx || !__IHidd_PixFmt || !__IHidd_ColorMap) + { + D(bug("Init_AmigaVideoClass fail\n")); + freeattrbases(csd); + return 0; + } + return TRUE; +} + + +static int Expunge_AmigaVideoClass(LIBBASETYPEPTR LIBBASE) +{ + struct amigavideo_staticdata *csd = &LIBBASE->csd; + D(bug("Expunge_AmigaVideoClass\n")); + freeattrbases(csd); + return TRUE; +} + +ADD2EXPUNGELIB(Expunge_AmigaVideoClass, 1) diff --git a/arch/m68k-amiga/hidd/amigavideo/blitter.c b/arch/m68k-amiga/hidd/amigavideo/blitter.c index 4ad4e6cc42..c2019ded73 100644 --- a/arch/m68k-amiga/hidd/amigavideo/blitter.c +++ b/arch/m68k-amiga/hidd/amigavideo/blitter.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. + Copyright © 1995-2017, The AROS Development Team. All rights reserved. $Id$ */ @@ -15,6 +15,7 @@ #include "amigavideo_bitmap.h" #include "blitter.h" +#define DEBUG 0 #include #define ABC 0x80 diff --git a/arch/m68k-amiga/hidd/amigavideo/chipset.c b/arch/m68k-amiga/hidd/amigavideo/chipset.c dissimilarity index 68% index 84ec9b58a9..6b46e89e98 100644 --- a/arch/m68k-amiga/hidd/amigavideo/chipset.c +++ b/arch/m68k-amiga/hidd/amigavideo/chipset.c @@ -1,1040 +1,992 @@ -/* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "amigavideo_hidd.h" -#include "amigavideo_bitmap.h" -#include "chipset.h" - -#include - -#define BPLCONMASK 0x8a55 - -static const UBYTE fetchunits[] = { 3,3,3,0, 4,3,3,0, 5,4,3,0 }; -static const UBYTE fm_maxplanes[] = { 3,2,1,0, 3,3,2,0, 3,3,3,0 }; - -/* reset to OCS defaults */ -void resetcustom(struct amigavideo_staticdata *csd) -{ - volatile struct Custom *custom = (struct Custom*)0xdff000; - struct GfxBase *GfxBase = (APTR)csd->cs_GfxBase; - - D( - bug("[AmigaVideo] %s()\n", __func__); - bug("[AmigaVideo] %s: GfxBase @ 0x%p\n", __func__, GfxBase); - ) - - GfxBase->system_bplcon0 &= ~BPLCONMASK; - GfxBase->system_bplcon0 |= 0x0200; - D(bug("[AmigaVideo] %s: bplcon0 = %04x\n", __func__, GfxBase->system_bplcon0)); - - custom->fmode = 0x0000; - custom->bplcon0 = GfxBase->system_bplcon0; - custom->bplcon1 = 0x0000; - custom->bplcon2 = 0x0024; - custom->bplcon3 = 0x0c00; - custom->bplcon4 = 0x0011; - custom->vposw = 0x8000; - custom->color[0] = 0x0444; - - // Use AGA modes and create AGA copperlists only if AGA is "enabled" - csd->aga_enabled = csd->aga && GfxBase->ChipRevBits0 == SETCHIPREV_AA; -} - -static void waitvblank(struct amigavideo_staticdata *csd) -{ - // ugly busy loop for now.. - UWORD fc = csd->framecounter; - while (fc == csd->framecounter); -} - -static void setnullsprite(struct amigavideo_staticdata *csd) -{ - if (csd->copper1_spritept) { - UWORD *p = csd->sprite_null; - csd->copper1_spritept[0] = (UWORD)(((ULONG)p) >> 16); - csd->copper1_spritept[2] = (UWORD)(((ULONG)p) >> 0); - } - } - -void resetsprite(struct amigavideo_staticdata *csd) -{ - UWORD *sprite = csd->sprite; - setnullsprite(csd); - csd->sprite = NULL; - FreeMem(sprite, csd->spritedatasize); - csd->sprite_width = csd->sprite_height = 0; -} - -static void setfmode(struct amigavideo_staticdata *csd) -{ - UWORD fmode; - fmode = csd->fmode_bpl == 2 ? 3 : csd->fmode_bpl; - fmode |= (csd->fmode_spr == 2 ? 3 : csd->fmode_spr) << 2; - if (csd->copper2.copper2_fmode) { - *csd->copper2.copper2_fmode = fmode; - if (csd->interlace) - *csd->copper2i.copper2_fmode = fmode; - } -} - -static void setcoppercolors(struct amigavideo_staticdata *csd) -{ - UWORD i; - - if (!csd->copper2.copper2_palette) - return; - if (csd->aga && csd->aga_enabled) { - UWORD off = 1; - for (i = 0; i < csd->use_colors; i++) { - UWORD vallo, valhi; - UBYTE r = csd->palette[i * 3 + 0]; - UBYTE g = csd->palette[i * 3 + 1]; - UBYTE b = csd->palette[i * 3 + 2]; - if ((i & 31) == 0) - off += 2; - valhi = ((r & 0xf0) << 4) | ((g & 0xf0)) | ((b & 0xf0) >> 4); - vallo = ((r & 0x0f) << 8) | ((g & 0x0f) << 4) | ((b & 0x0f)); - csd->copper2.copper2_palette[i * 2 + off] = valhi; - csd->copper2.copper2_palette_aga_lo[i * 2 + off] = vallo; - if (csd->interlace) { - csd->copper2i.copper2_palette[i * 2 + off] = valhi; - csd->copper2i.copper2_palette_aga_lo[i * 2 + off] = vallo; - } - } - } else if (csd->res == 2 && !csd->aga) { - /* ECS "scrambled" superhires */ - for (i = 0; i < csd->use_colors; i++) { - UBYTE offset = i < 16 ? 0 : 16; - UBYTE c1 = (i & 3) + offset; - UBYTE c2 = ((i >> 2) & 3) + offset; - UWORD val1 = ((csd->palette[c1 * 3 + 0] >> 4) << 8) | ((csd->palette[c1 * 3 + 1] >> 4) << 4) | ((csd->palette[c1 * 3 + 2] >> 4) << 0); - UWORD val2 = ((csd->palette[c2 * 3 + 0] >> 4) << 8) | ((csd->palette[c2 * 3 + 1] >> 4) << 4) | ((csd->palette[c2 * 3 + 2] >> 4) << 0); - UWORD val = (val1 & 0xccc) | ((val2 & 0xccc) >> 2); - csd->copper2.copper2_palette[i * 2 + 1] = val; - if (csd->interlace) - csd->copper2i.copper2_palette[i * 2 + 1] = val; - } - - } else { - for (i = 0; i < csd->use_colors; i++) { - UWORD val = ((csd->palette[i * 3 + 0] >> 4) << 8) | ((csd->palette[i * 3 + 1] >> 4) << 4) | ((csd->palette[i * 3 + 2] >> 4) << 0); - csd->copper2.copper2_palette[i * 2 + 1] = val; - if (csd->interlace) - csd->copper2i.copper2_palette[i * 2 + 1] = val; - } - } -} - -static void setpalntsc(struct amigavideo_staticdata *csd, ULONG modeid) -{ - volatile struct Custom *custom = (struct Custom*)0xdff000; - struct GfxBase *GfxBase = (APTR)csd->cs_GfxBase; - - csd->palmode = (GfxBase->DisplayFlags & NTSC) == 0; - if (!csd->ecs_agnus) - return; - if ((modeid & MONITOR_ID_MASK) == PAL_MONITOR_ID) { - custom->beamcon0 = 0x0020; - csd->palmode = TRUE; - } else if ((modeid & MONITOR_ID_MASK) == NTSC_MONITOR_ID) { - custom->beamcon0 = 0x0000; - csd->palmode = FALSE; - } else { - custom->beamcon0 = (GfxBase->DisplayFlags & NTSC) ? 0x0000 : 0x0020; - } -} - -void resetmode(struct amigavideo_staticdata *csd) -{ - volatile struct Custom *custom = (struct Custom*)0xdff000; - struct GfxBase *GfxBase = (APTR)csd->cs_GfxBase; - - D(bug("[AmigaVideo] %s()\n", __func__)); - - csd->disp = NULL; - - custom->dmacon = 0x0100; - setpalntsc(csd, 0); - - custom->cop2lc = (ULONG)csd->copper2_backup; - custom->copjmp2 = 0; - - waitvblank(csd); - - FreeVec(csd->copper2.copper2); - csd->copper2.copper2 = NULL; - FreeVec(csd->copper2i.copper2); - csd->copper2i.copper2 = NULL; - - GfxBase->LOFlist = GfxBase->SHFlist = csd->copper2_backup; - - resetcustom(csd); - - csd->depth = 0; -} - -/* Use nominal screen height. Overscan is not supported yet. */ -static WORD limitheight(struct amigavideo_staticdata *csd, WORD y, BOOL lace, BOOL maxlimit) -{ - if (lace) - y /= 2; - if (csd->palmode) { - if (maxlimit && y > 311) - y = 311; - else if (!maxlimit && y > 256) - y = 256; - } else { - if (maxlimit && y > 261) - y = 261; - else if (!maxlimit && y > 200) - y = 200; - } - if (lace) - y *= 2; - return y; -} - -static void setcopperscroll2(struct amigavideo_staticdata *csd, struct amigabm_data *bm, struct copper2data *c2d, BOOL odd) -{ - UWORD *copptr = c2d->copper2_scroll, *copbpl; - WORD xscroll, yscroll; - WORD x, y; - WORD ystart, yend, i, xdelay; - WORD xmaxscroll, modulo, ddfstrt, fmodewidth, minearly; - LONG offset; - - fmodewidth = 16 << csd->fmode_bpl; - x = bm->leftedge; - y = csd->starty + (bm->topedge >> csd->interlace); - - yscroll = 0; - if (y < 10) { - yscroll = y - 10; - y = 10; - } - - xmaxscroll = 1 << (1 + csd->fmode_bpl); - xdelay = x & (fmodewidth - 1); - xscroll = -x; - - yend = y + (bm->displayheight >> csd->interlace); - yend = limitheight(csd, yend, FALSE, TRUE); - ystart = y - csd->extralines; - - modulo = (csd->interlace ? bm->bytesperrow : 0) + csd->modulo; - ddfstrt = csd->ddfstrt; - - offset = ((xscroll + (xmaxscroll << 3) - 1) >> 3) & ~(xmaxscroll - 1); - offset -= (yscroll * bm->bytesperrow) << (csd->interlace ? 1 : 0); - - minearly = 1 << fetchunits[csd->fmode_bpl * 4 + csd->res]; - if (xdelay) { - ddfstrt -= minearly; - modulo -= (minearly << csd->res) / 4; - offset -= (minearly << csd->res) / 4; - } - - copptr[1] = (y << 8) | (csd->startx); //(y << 8) + (x + 1); - copptr[3] = (yend << 8) | ((csd->startx + 0x140) & 0xff); //((y + (bm->rows >> csd->interlace)) << 8) + ((x + 1 + (bm->width >> csd->res)) & 0x00ff); - copptr[5] = ((y >> 8) & 7) | (((yend >> 8) & 7) << 8) | 0x2000; - - copbpl = c2d->copper2_bpl; - for (i = 0; i < bm->depth; i++) { - ULONG pptr = (ULONG)(bm->pbm->Planes[csd->bploffsets[i]]); - if (csd->interlace && odd) - pptr += bm->bytesperrow; - pptr += offset; - copbpl[1] = (UWORD)(pptr >> 16); - copbpl[3] = (UWORD)(pptr >> 0); - copbpl += 4; - } - - xdelay <<= 2 - csd->res; - copptr[11] = - (((xdelay >> 2) & 0x0f) << 0) | (((xdelay >> 2) & 0x0f) << 4) - | ((xdelay >> 6) << 10) | ((xdelay >> 6) << 14) - | ((xdelay & 3) << 8) | ((xdelay & 3) << 12); - - copptr[7] = ddfstrt; - copptr[9] = csd->ddfstop; - copptr[13] = modulo; - copptr[15] = modulo; - - yend = y + bm->displayheight + yscroll; - yend = limitheight(csd, yend, FALSE, TRUE); - copptr = c2d->copper2_bplcon0; - copptr[4] = (yend << 8) | 0x05; - if (yend < 256 || ystart >= 256) { - copptr[2] = 0x00df; - copptr[3] = 0x00fe; - } else { - copptr[2] = 0xffdf; - copptr[3] = 0xfffe; - } - - copptr = c2d->copper2; - if (ystart >= 256) - copptr[0] = 0xffdf; - else - copptr[0] = 0x01fe; - copptr[2] = (ystart << 8) | 0x05; - copptr = c2d->copper2_bplcon0; - copptr[-2] = (y << 8) | 0x05; -} - -static void setcopperscroll(struct amigavideo_staticdata *csd, struct amigabm_data *bm) -{ - setcopperscroll2(csd, bm, &csd->copper2, FALSE); - if (csd->interlace) - setcopperscroll2(csd, bm, &csd->copper2i, TRUE); -} - -static UWORD get_copper_list_length(struct amigavideo_staticdata *csd, UBYTE depth) -{ - UWORD v; - - if (csd->aga && csd->aga_enabled) { - v = 1000 + ((1 << depth) + 1 + (1 << depth) / 32 + 1) * 2; - } else { - v = 1000; - } - return v * 2; -} - -static void createcopperlist(struct amigavideo_staticdata *csd, struct amigabm_data *bm, struct copper2data *c2d, BOOL lace) -{ - struct GfxBase *GfxBase = (struct GfxBase *)csd->cs_GfxBase; - volatile WORD *system_bplcon0 = (volatile WORD *)&GfxBase->system_bplcon0; - UWORD *c; - UWORD i; - UWORD bplcon0, bplcon0_res; - ULONG pptr; - - D(bug("[AmigaVideo] %s()\n", __func__)); - D(bug("[AmigaVideo] %s: GfxBase @ 0x%p\n", __func__, GfxBase)); - D(bug("[AmigaVideo] %s: system_bplcon0 @ 0x%p\n", __func__, system_bplcon0)); - - c = c2d->copper2; - D(bug("[AmigaVideo] %s: Copperlist%d %p\n", __func__, lace ? 2 : 1, c)); - - bplcon0_res = *system_bplcon0 & ~BPLCONMASK; - D(bug("[AmigaVideo] %s: bplcon0_res = %04x\n", __func__, bplcon0_res)); - - if (csd->res == 1) - bplcon0_res |= 0x8000; - else if (csd->res == 2) - bplcon0_res |= 0x0040; - else - bplcon0_res = 0; - - csd->bplcon0_null = 0x0201 | (csd->interlace ? 4 : 0) | bplcon0_res; - csd->bplcon3 = ((csd->sprite_res + 1) << 6) | 2; // spriteres + bordersprite - - *c++ = 0x01fe; - *c++ = 0xfffe; - *c++ = 0xffff; - *c++ = 0xfffe; - - *c++ = 0x0100; - *c++ = csd->bplcon0_null; - - c2d->copper2_bpl = c; - for (i = 0; i < bm->depth; i++) { - pptr = (ULONG)(bm->pbm->Planes[csd->bploffsets[i]]); - if (lace) - pptr += bm->bytesperrow; - *c++ = 0xe0 + i * 4; - *c++ = (UWORD)(pptr >> 16); - *c++ = 0xe2 + i * 4; - *c++ = (UWORD)(pptr >> 0); - } - - csd->use_colors = 1 << bm->depth; - // need to update sprite colors - if (csd->use_colors < 16 + 4) - csd->use_colors = 16 + 4; - if (csd->res == 2 && !csd->aga) - csd->use_colors = 32; /* ECS "scrambled" superhires */ - - if (csd->use_colors > 32 && (csd->modeid & EXTRAHALFBRITE_KEY)) - csd->use_colors = 32; - if (csd->modeid & HAM_KEY) { - if (bm->depth <= 6) - csd->use_colors = 16 + 4; - else - csd->use_colors = 64; - } - - c2d->copper2_scroll = c; - *c++ = 0x008e; - *c++ = 0; - *c++ = 0x0090; - *c++ = 0; - *c++ = 0x01e4; - *c++ = 0; - *c++ = 0x0092; - *c++ = 0; - *c++ = 0x0094; - *c++ = 0; - *c++ = 0x0102; - *c++ = 0; - *c++ = 0x0108; - *c++ = 0; - *c++ = 0x010a; - *c++ = 0; - *c++ = 0x0104; - *c++ = 0x0024 | ((csd->aga && !(csd->modeid & EXTRAHALFBRITE_KEY)) ? 0x0200 : 0); - - c2d->copper2_fmode = NULL; - if (csd->aga && csd->aga_enabled) { - *c++ = 0x010c; - *c++ = 0x0011; - *c++ = 0x01fc; - c2d->copper2_fmode = c; - *c++ = 0; - } - - bplcon0 = csd->bplcon0_null; - if (bm->depth > 7) - bplcon0 |= 0x0010; - else - bplcon0 |= bm->depth << 12; - if (csd->modeid & HAM_KEY) - bplcon0 |= 0x0800; - - *system_bplcon0 = (*system_bplcon0 & ~BPLCONMASK) | bplcon0; - D(bug("[AmigaVideo] %s: system_bplcon0 = %04x\n", __func__, *system_bplcon0)); - - c2d->copper2_palette = c; - if (csd->aga && csd->aga_enabled) { - // hi - for (i = 0; i < csd->use_colors; i++) { - UBYTE agac = i & 31; - if (agac == 0) { - *c++ = 0x106; - *c++ = csd->bplcon3 | ((i / 32) << 13); - } - *c++ = 0x180 + agac * 2; - *c++ = 0x000; - } - c2d->copper2_palette_aga_lo = c; - // lo - for (i = 0; i < csd->use_colors; i++) { - UBYTE agac = i & 31; - if (agac == 0) { - *c++ = 0x106; - *c++ = csd->bplcon3 | ((i / 32) << 13) | 0x0200; - } - *c++ = 0x180 + agac * 2; - *c++ = 0x000; - } - *c++ = 0x106; - *c++ = csd->bplcon3; - } else { - // ocs/ecs - for (i = 0; i < csd->use_colors; i++) { - *c++ = 0x180 + i * 2; - *c++ = 0x000; - } - } - - csd->extralines = (c - c2d->copper2) / 112 + 1; - - *c++ = 0xffff; - *c++ = 0xfffe; - c2d->copper2_bplcon0 = c; - *c++ = 0x0100; - *c++ = bplcon0; - - *c++ = 0xffff; - *c++ = 0xfffe; - *c++ = 0xffff; - *c++ = 0xfffe; - - *c++ = 0x0100; - *c++ = csd->bplcon0_null; - - if (csd->interlace) { - ULONG nextptr = (ULONG)(lace ? csd->copper2.copper2 : csd->copper2i.copper2); - *c++ = 0x0084; - *c++ = (UWORD)(nextptr >> 16); - *c++ = 0x0086; - *c++ = (UWORD)(nextptr >> 0); - } - *c++ = 0xffff; - *c++ = 0xfffe; - -} - -BOOL setbitmap(struct amigavideo_staticdata *csd, struct amigabm_data *bm) -{ - csd->width = bm->width; - csd->height = csd->interlace ? (bm->height + 1) / 2 : bm->height; - csd->modulo = bm->bytesperrow - csd->modulopre / (4 >> csd->res); - csd->modulo &= ~((2 << csd->fmode_bpl) - 1); - csd->updatescroll = bm; - csd->depth = bm->depth; - setcopperscroll(csd, bm); - - D(bug("setbitmap bm=%x mode=%08x w=%d h=%d d=%d bpr=%d\n", - bm, csd->modeid, bm->width, bm->height, bm->depth, bm->bytesperrow)); - return TRUE; -} - -BOOL setmode(struct amigavideo_staticdata *csd, struct amigabm_data *bm) -{ - volatile struct Custom *custom = (struct Custom*)0xdff000; - struct GfxBase *GfxBase = (APTR)csd->cs_GfxBase; - UWORD ddfstrt, ddfstop; - UBYTE fetchunit, maxplanes; - UWORD bplwidth, viewwidth; - UBYTE i; - - if (csd->disp == bm) - return TRUE; - - resetmode(csd); - - csd->res = 0; - if ((csd->modeid & SUPER_KEY) == SUPER_KEY) - csd->res = 2; - else if ((csd->modeid & SUPER_KEY) == HIRES_KEY) - csd->res = 1; - csd->interlace = (csd->modeid & LORESLACE_KEY) ? 1 : 0; - csd->fmode_bpl = csd->aga && csd->aga_enabled ? 2 : 0; - - fetchunit = fetchunits[csd->fmode_bpl * 4 + csd->res]; - maxplanes = fm_maxplanes[csd->fmode_bpl * 4 + csd->res]; - - D(bug("res %d fmode %d depth %d maxplanes %d aga %d agae %d\n", - csd->res, csd->fmode_bpl, bm->depth, maxplanes, csd->aga, csd->aga_enabled)); - - if (bm->depth > (1 << maxplanes)) { - if (csd->aga && !csd->aga_enabled) { - // Enable AGA if requesting AGA only mode. - // This is a compatibility hack because our display - // database currently contains all AGA modes even if AGA - // is "disabled". - GfxBase->ChipRevBits0 = SETCHIPREV_AA; - csd->aga_enabled = TRUE; - csd->fmode_bpl = csd->aga && csd->aga_enabled ? 2 : 0; - fetchunit = fetchunits[csd->fmode_bpl * 4 + csd->res]; - maxplanes = fm_maxplanes[csd->fmode_bpl * 4 + csd->res]; - } - if (bm->depth > (1 << maxplanes)) - return FALSE; - } - - viewwidth = bm->width; - // use nominal width for now - if ((viewwidth << csd->res) > 320) - viewwidth = 320 << csd->res; - - D(bug("setmode bm=%x mode=%08x w=%d h=%d d=%d bpr=%d fu=%d\n", - bm, csd->modeid, bm->width, bm->height, bm->depth, bm->bytesperrow, fetchunit)); - - bplwidth = viewwidth >> (csd->res + 1); - ddfstrt = (csd->startx / 2) & ~((1 << fetchunit) - 1); - ddfstop = ddfstrt + ((bplwidth + ((1 << fetchunit) - 1) - 2 * (1 << fetchunit)) & ~((1 << fetchunit) - 1)); - csd->modulopre = ddfstop + 2 * (1 << fetchunit) - ddfstrt; - ddfstrt -= 1 << maxplanes; - csd->ddfstrt = ddfstrt; - csd->ddfstop = ddfstop; - - for (i = 0; i < 8; i++) - csd->bploffsets[i] = i; - if ((csd->modeid & HAM_KEY) && bm->depth > 6) { - csd->bploffsets[0] = 6; - csd->bploffsets[1] = 7; - for (i = 0; i < 6; i++) - csd->bploffsets[i + 2] = i; - } - - csd->copper2.copper2 = AllocVec(get_copper_list_length(csd, bm->depth), MEMF_CLEAR | MEMF_CHIP); - if (csd->interlace) - csd->copper2i.copper2 = AllocVec(get_copper_list_length(csd, bm->depth), MEMF_CLEAR | MEMF_CHIP); - createcopperlist(csd, bm, &csd->copper2, FALSE); - if (csd->interlace) { - createcopperlist(csd, bm, &csd->copper2i, TRUE); - } - - setfmode(csd); - setpalntsc(csd, csd->modeid); - custom->bplcon0 = csd->bplcon0_null; - - bm->displaywidth = viewwidth; - bm->displayheight = limitheight(csd, bm->height, csd->interlace, FALSE); - - setbitmap(csd, bm); - - GfxBase->LOFlist = csd->copper2.copper2; - GfxBase->SHFlist = csd->interlace ? csd->copper2i.copper2 : csd->copper2.copper2; - custom->dmacon = 0x8100; - - setcoppercolors(csd); - setspritepos(csd, csd->spritex, csd->spritey); - - csd->disp = bm; - return 1; - } - -UBYTE av__PickPen(struct amigavideo_staticdata *csd, ULONG pixel) -{ - UBYTE retval = 1; - return retval; -} - -BOOL setsprite(OOP_Class *cl, OOP_Object *o, WORD width, WORD height, struct pHidd_Gfx_SetCursorShape *msg) -{ - struct amigavideo_staticdata *csd = CSD(cl); - struct Library *OOPBase = csd->cs_OOPBase; - OOP_MethodID HiddGfxBase = csd->cs_HiddGfxBase; - OOP_MethodID HiddBitMapBase = csd->cs_HiddBitMapBase; - OOP_Object *bmPFObj = NULL; - HIDDT_PixelFormat *bmPF; - IPTR pf, bmcmod; - UWORD fetchsize; - UWORD bitmapwidth = width; - UWORD y, *p; - - OOP_GetAttr(msg->shape, aHidd_BitMap_PixFmt, (IPTR*)&bmPFObj); - OOP_GetAttr(bmPFObj, aHidd_PixFmt_ColorModel, &bmcmod); - if (bmcmod == vHidd_ColorModel_TrueColor) - { - OOP_GetAttr(bmPFObj, aHidd_PixFmt_StdPixFmt, (IPTR*)&pf); - bmPF = (HIDDT_PixelFormat *)HIDD_Gfx_GetPixFmt(o, pf); - } - - if (csd->aga && csd->aga_enabled && width > 16) - csd->fmode_spr = 2; - else - csd->fmode_spr = 0; - fetchsize = 2 << csd->fmode_spr; - width = 16 << csd->fmode_spr; - - if (width != csd->sprite_width || height != csd->sprite_height) { - resetsprite(csd); - csd->spritedatasize = fetchsize * 2 + fetchsize * height * 2 + fetchsize * 2; - csd->sprite = AllocMem(csd->spritedatasize, MEMF_CHIP | MEMF_CLEAR); - if (!csd->sprite) - return FALSE; - csd->sprite_width = width; - csd->sprite_height = height; - csd->sprite_offset_x = msg->xoffset; - csd->sprite_offset_y = msg->yoffset; - } - p = csd->sprite; - p += fetchsize; - for(y = 0; y < height; y++) { - UWORD xx, xxx, x; - for (xx = 0, xxx = 0; xx < width; xx += 16, xxx++) { - UWORD pix1 = 0, pix2 = 0; - for(x = 0; x < 16; x++) { - UBYTE c = 0; - if (xx + x < bitmapwidth) - { - if (bmcmod != vHidd_ColorModel_TrueColor) - c = HIDD_BM_GetPixel(msg->shape, x, y); - else - { - HIDDT_Pixel pix = HIDD_BM_GetPixel(msg->shape, x, y); - c = 0; - if ((ALPHA_COMP(pix, bmPF) & 0xFF00) == 0xFF00) - c = av__PickPen(csd, ((RED_COMP(pix, bmPF) & 0xFF00) << 8) | (GREEN_COMP(pix, bmPF) & 0xFF00) | ((BLUE_COMP(pix, bmPF) >> 8) & 0xFF)); - else c = 0; - } - } - pix1 <<= 1; - pix2 <<= 1; - pix1 |= (c & 1) ? 1 : 0; - pix2 |= (c & 2) ? 1 : 0; - } - p[xxx] = pix1; - p[xxx + fetchsize / 2] = pix2; - } - p += fetchsize; - } - setspritepos(csd, csd->spritex, csd->spritey); - setspritevisible(csd, csd->cursorvisible); - return TRUE; -} - -void setspritepos(struct amigavideo_staticdata *csd, WORD x, WORD y) -{ - UWORD ctl, pos; - - csd->spritex = x; - csd->spritey = y; - if (!csd->sprite || csd->sprite_height == 0) - return; - - x += csd->sprite_offset_x << csd->res; - x <<= (2 - csd->res); // convert x to shres coordinates - x += (csd->startx - 1) << 2; // display left edge offset - - if (csd->interlace) - y /= 2; // y is always in nonlaced - y += csd->starty; - y += csd->sprite_offset_y; - - pos = (y << 8) | (x >> 3); - ctl = ((y + csd->sprite_height) << 8); - ctl |= ((y >> 8) << 2) | (((y + csd->sprite_height) >> 8) << 1) | ((x >> 2) & 1) | ((x & 3) << 3); - csd->spritepos = pos; - csd->spritectl = ctl; -} - -void setspritevisible(struct amigavideo_staticdata *csd, BOOL visible) -{ - csd->cursorvisible = visible; - if (visible) { - if (csd->copper1_spritept) { - UWORD *p = csd->sprite; - setfmode(csd); - csd->copper1_spritept[0] = (UWORD)(((ULONG)p) >> 16); - csd->copper1_spritept[2] = (UWORD)(((ULONG)p) >> 0); -} - } else { - setnullsprite(csd); - } -} - -BOOL setcolors(struct amigavideo_staticdata *csd, struct pHidd_BitMap_SetColors *msg, BOOL visible) -{ - UWORD i, j; - if (msg->firstColor + msg->numColors > csd->max_colors) - return FALSE; - j = 0; - for (i = msg->firstColor; j < msg->numColors; i++, j++) { - UBYTE red, green, blue; - red = msg->colors[j].red >> 8; - green = msg->colors[j].green >> 8; - blue = msg->colors[j].blue >> 8; - csd->palette[i * 3 + 0] = red; - csd->palette[i * 3 + 1] = green; - csd->palette[i * 3 + 2] = blue; - //bug("%d: %02x %02x %02x\n", i, red, green, blue); - } - if (visible) - setcoppercolors(csd); - return TRUE; -} -void setscroll(struct amigavideo_staticdata *csd, struct amigabm_data *bm) -{ - csd->updatescroll = bm; -} - -/* Convert Z flag to normal C-style return variable. Fun. */ -UBYTE bltnode_wrapper(void) -{ - UBYTE ret; - asm volatile ( - " pea 1f\n" - " move.l 4(%%a1),-(%%sp)\n" - " rts\n" - "1: sne %d0\n" - " move.b %%d0,%0\n" - : "=g" (ret) - ); - return ret; -} - -#define BEAMSYNC_ALARM 0x0f00 -/* AOS must use some GfxBase flags field for these. Later.. */ -#define bqvar GfxBase->pad3 -#define BQ_NEXT 1 -#define BQ_BEAMSYNC 2 -#define BQ_BEAMSYNCWAITING 4 -#define BQ_MISSED 8 - -static AROS_INTH1(gfx_blit, struct GfxBase *, GfxBase) -{ - AROS_INTFUNC_INIT - - volatile struct Custom *custom = (struct Custom*)0xdff000; - struct bltnode *bn = NULL; - UBYTE v; - UWORD dmaconr; - - dmaconr = custom->dmaconr; - dmaconr = custom->dmaconr; - if (dmaconr & 0x4000) { - /* Blitter still active? Wait for next interrupt. */ - return 0; - } - - if (GfxBase->blthd == NULL && GfxBase->bsblthd == NULL) { - custom->intena = INTF_BLIT; - return 0; - } - - /* Was last blit in this node? */ - if (bqvar & BQ_NEXT) { - bqvar &= ~(BQ_NEXT | BQ_MISSED); - if (bqvar & BQ_BEAMSYNC) - bn = GfxBase->bsblthd; - else - bn = GfxBase->blthd; - if (bn->stat == CLEANUP) - AROS_UFC2(UBYTE, bn->cleanup, - AROS_UFCA(struct Custom *, custom, A0), - AROS_UFCA(struct bltnode*, bn, A1)); - /* Next node */ - bn = bn->n; - if (bqvar & BQ_BEAMSYNC) - GfxBase->bsblthd = bn; - else - GfxBase->blthd = bn; - } - - if (GfxBase->bsblthd) { - bn = GfxBase->bsblthd; - bqvar |= BQ_BEAMSYNC; - } else if (GfxBase->blthd) { - bn = GfxBase->blthd; - bqvar &= ~BQ_BEAMSYNC; - } - - if (!bn) { - /* Last blit finished */ - bqvar = 0; - custom->intena = INTF_BLIT; - GfxBase->blthd = GfxBase->bsblthd = NULL; - DisownBlitter(); - return 0; - } - - if (bqvar & BQ_BEAMSYNC) { - UWORD vpos = VBeamPos(); - bqvar &= ~BQ_BEAMSYNCWAITING; - if (!(bqvar & BQ_MISSED) && bn->beamsync > vpos) { - volatile struct CIA *ciab = (struct CIA*)0xbfd000; - UWORD w = BEAMSYNC_ALARM - (bn->beamsync - vpos); - bqvar |= BQ_BEAMSYNCWAITING; - ciab->ciacrb &= ~0x80; - ciab->ciatodhi = 0; - ciab->ciatodmid = w >> 8; - ciab->ciatodlow = w; - return 0; - } - } - - v = AROS_UFC2(UBYTE, bltnode_wrapper, - AROS_UFCA(struct Custom *, custom, A0), - AROS_UFCA(struct bltnode*, bn, A1)); - - dmaconr = custom->dmaconr; - dmaconr = custom->dmaconr; - if (!(dmaconr & 0x4000)) { - /* Eh? Blitter not active?, better fake the interrupt. */ - custom->intreq = INTF_SETCLR | INTF_BLIT; - } - - if (v) { - /* Handle same node again next time */ - return 0; - } - - bqvar |= BQ_NEXT; - - return 0; - - AROS_INTFUNC_EXIT -} - -static AROS_INTH1(gfx_beamsync, struct amigavideo_staticdata*, csd) -{ - AROS_INTFUNC_INIT - - struct GfxBase *GfxBase = (APTR)csd->cs_GfxBase; - - if (bqvar & BQ_BEAMSYNCWAITING) { - /* We only need to trigger blitter interrupt */ - volatile struct Custom *custom = (struct Custom*)0xdff000; - custom->intreq = INTF_SETCLR | INTF_BLIT; - } - - return FALSE; - - AROS_INTFUNC_EXIT -} - -static AROS_INTH1(gfx_vblank, struct amigavideo_staticdata*, csd) -{ - AROS_INTFUNC_INIT - - struct GfxBase *GfxBase = (APTR)csd->cs_GfxBase; - volatile struct Custom *custom = (struct Custom*)0xdff000; - BOOL lof = (custom->vposr & 0x8000) != 0; - - if (csd->interlace) { - custom->cop2lc = (ULONG)(lof ? GfxBase->LOFlist : GfxBase->SHFlist); - } else { - custom->cop2lc = (ULONG)GfxBase->LOFlist; - /* We may be in SHF mode after switching interlace off. Fix it here. */ - if (!lof) - custom->vposw = custom->vposr | 0x8000; - } - - csd->framecounter++; - if (csd->sprite) { - UWORD *p = csd->sprite; - p[0] = csd->spritepos; - p[1 << csd->fmode_spr] = csd->spritectl; - } - - if (csd->updatescroll) { - setcopperscroll(csd, csd->updatescroll); - csd->updatescroll = NULL; - } - - if (bqvar & BQ_BEAMSYNC) - bqvar |= BQ_MISSED; - - return FALSE; - - AROS_INTFUNC_EXIT -} - -void initcustom(struct amigavideo_staticdata *csd) -{ - UBYTE i; - UWORD *c; - UWORD vposr, val; - struct GfxBase *GfxBase; - struct Library *OOPBase; - volatile struct Custom *custom = (struct Custom*)0xdff000; - volatile struct CIA *ciab = (struct CIA*)0xbfd000; - - D(bug("[AmigaVideo] %s()\n", __func__)); - - /* Reset audio registers to values that help emulation - * if some program enables audio DMA without setting period - * or length. Very high period emulation is very CPU intensive. - */ - for (i = 0; i < 4; i++) { - custom->aud[i].ac_vol = 0; - custom->aud[i].ac_per = 100; - custom->aud[i].ac_len = 1000; - } - - /* csd->cs_OOPBase was already set up. - * See amigavideo.conf's 'oopbase_field' config - */ - OOPBase = csd->cs_OOPBase; - csd->cs_HiddBitMapBase = OOP_GetMethodID(IID_Hidd_BitMap, 0); - csd->cs_HiddGfxBase = OOP_GetMethodID(IID_Hidd_Gfx, 0); - - csd->cs_UtilityBase = TaggedOpenLibrary(TAGGEDOPEN_UTILITY); - if (!csd->cs_UtilityBase) - Alert(AT_DeadEnd | AN_Hidd | AG_OpenLib | AO_UtilityLib); - csd->cs_GfxBase = TaggedOpenLibrary(TAGGEDOPEN_GRAPHICS); - if (!csd->cs_GfxBase) - Alert(AT_DeadEnd | AN_Hidd | AG_OpenLib | AO_GraphicsLib); - GfxBase = ((struct GfxBase *)csd->cs_GfxBase); - GfxBase->cia = OpenResource("ciab.resource"); - - /* Reset now we have the bases */ - resetcustom(csd); - resetsprite(csd); - - csd->inter.is_Code = (APTR)gfx_vblank; - csd->inter.is_Data = csd; - csd->inter.is_Node.ln_Name = "GFX VBlank server"; - csd->inter.is_Node.ln_Pri = 25; - csd->inter.is_Node.ln_Type = NT_INTERRUPT; - AddIntServer(INTB_VERTB, &csd->inter); - - /* There are programs that take over the system and - * assume SysBase->IntVects[BLITTER].iv_Data = GfxBase! - */ - GfxBase->bltsrv.is_Code = (APTR)gfx_blit; - GfxBase->bltsrv.is_Data = GfxBase; - GfxBase->bltsrv.is_Node.ln_Name = "Blitter"; - GfxBase->bltsrv.is_Node.ln_Type = NT_INTERRUPT; - SetIntVector(INTB_BLIT, &GfxBase->bltsrv); - custom->intena = INTF_BLIT; - - // CIA-B TOD counts scanlines */ - GfxBase->timsrv.is_Code = (APTR)gfx_beamsync; - GfxBase->timsrv.is_Data = csd; - GfxBase->timsrv.is_Node.ln_Name = "Beamsync"; - GfxBase->timsrv.is_Node.ln_Type = NT_INTERRUPT; - Disable(); - AddICRVector(GfxBase->cia, 2, &GfxBase->timsrv); - AbleICR(GfxBase->cia, 1 << 2); - ciab->ciacrb |= 0x80; - ciab->ciatodhi = 0; - /* TOD/ALARM CIA bug: http://eab.abime.net/showpost.php?p=277315&postcount=10 */ - ciab->ciatodmid = BEAMSYNC_ALARM >> 8; - ciab->ciatodlow = BEAMSYNC_ALARM & 0xff; - ciab->ciacrb &= ~0x80; - ciab->ciatodhi = 0; - ciab->ciatodmid = 0; - ciab->ciatodlow = 0; - AbleICR(GfxBase->cia, 0x80 | (1 << 2)); - Enable(); - - GfxBase->NormalDisplayColumns = 640; - GfxBase->NormalDisplayRows = (GfxBase->DisplayFlags & NTSC) ? 200 : 256; - GfxBase->MaxDisplayColumn = 640; - GfxBase->MaxDisplayRow = (GfxBase->DisplayFlags & NTSC) ? 200 : 256; - - csd->startx = 0x81; - csd->starty = 0x28; - - vposr = custom->vposr & 0x7f00; - csd->aga = vposr >= 0x2200; - csd->ecs_agnus = vposr >= 0x2000; - val = custom->deniseid; - custom->deniseid = custom->dmaconr;; - if (val == custom->deniseid) { - custom->deniseid = custom->dmaconr ^ 0x8000; - if (val == custom->deniseid) { - if ((val & (2 + 8)) == 8) - csd->ecs_denise = TRUE; - } - } - csd->max_colors = csd->aga ? 256 : 32; - csd->palette = AllocVec(csd->max_colors * 3, MEMF_CLEAR); - csd->copper1 = AllocVec(22 * 2 * sizeof(WORD), MEMF_CLEAR | MEMF_CHIP); - csd->sprite_null = AllocMem(2 * 8, MEMF_CLEAR | MEMF_CHIP); - csd->sprite_res = 0; /* lores */ - c = csd->copper1; - for (i = 0; i < 8; i++) { - *c++ = 0x0120 + i * 4; - if (i == 0) - csd->copper1_spritept = c; - *c++ = (UWORD)(((ULONG)csd->sprite_null) >> 16); - *c++ = 0x0122 + i * 4; - *c++ = (UWORD)(((ULONG)csd->sprite_null) >> 0); - } - *c++ = 0x0c03; - *c++ = 0xfffe; - *c++ = 0x008a; - *c++ = 0x0000; - csd->copper2_backup = c; - *c++ = 0xffff; - *c++ = 0xfffe; - custom->cop1lc = (ULONG)csd->copper1; - custom->cop2lc = (ULONG)csd->copper2_backup; - custom->dmacon = 0x8000 | 0x0080 | 0x0040 | 0x0020; - - GfxBase->copinit = (struct copinit*)csd->copper1; - - D(bug("Copperlist0 %p\n", csd->copper1)); - -} +/* + Copyright © 1995-2017, The AROS Development Team. All rights reserved. + $Id$ +*/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "amigavideo_hidd.h" +#include "amigavideo_bitmap.h" +#include "chipset.h" + +#define DEBUG 0 +#include + +static const UBYTE fetchunits[] = { 3,3,3,0, 4,3,3,0, 5,4,3,0 }; +static const UBYTE fm_maxplanes[] = { 3,2,1,0, 3,3,2,0, 3,3,3,0 }; + +/* reset to OCS defaults */ +void resetcustom(struct amigavideo_staticdata *data) +{ + volatile struct Custom *custom = (struct Custom*)0xdff000; + struct GfxBase *GfxBase = (APTR)data->cs_GfxBase; + + custom->fmode = 0x0000; + custom->bplcon0 = 0x0200; + custom->bplcon1 = 0x0000; + custom->bplcon2 = 0x0024; + custom->bplcon3 = 0x0c00; + custom->bplcon4 = 0x0011; + custom->vposw = 0x8000; + custom->color[0] = 0x0444; + + // Use AGA modes and create AGA copperlists only if AGA is "enabled" + data->aga_enabled = data->aga && GfxBase->ChipRevBits0 == SETCHIPREV_AA; +} + +static void waitvblank(struct amigavideo_staticdata *data) +{ + // ugly busy loop for now.. + UWORD fc = data->framecounter; + while (fc == data->framecounter); +} + +static void setnullsprite(struct amigavideo_staticdata *data) +{ + if (data->copper1_spritept) { + UWORD *p = data->sprite_null; + data->copper1_spritept[0] = (UWORD)(((ULONG)p) >> 16); + data->copper1_spritept[2] = (UWORD)(((ULONG)p) >> 0); + } + } + +void resetsprite(struct amigavideo_staticdata *data) +{ + UWORD *sprite = data->sprite; + setnullsprite(data); + data->sprite = NULL; + FreeMem(sprite, data->spritedatasize); + data->sprite_width = data->sprite_height = 0; +} + +static void setfmode(struct amigavideo_staticdata *data) +{ + UWORD fmode; + fmode = data->fmode_bpl == 2 ? 3 : data->fmode_bpl; + fmode |= (data->fmode_spr == 2 ? 3 : data->fmode_spr) << 2; + if (data->copper2.copper2_fmode) { + *data->copper2.copper2_fmode = fmode; + if (data->interlace) + *data->copper2i.copper2_fmode = fmode; + } +} + +static void setcoppercolors(struct amigavideo_staticdata *data) +{ + UWORD i; + + if (!data->copper2.copper2_palette) + return; + if (data->aga && data->aga_enabled) { + UWORD off = 1; + for (i = 0; i < data->use_colors; i++) { + UWORD vallo, valhi; + UBYTE r = data->palette[i * 3 + 0]; + UBYTE g = data->palette[i * 3 + 1]; + UBYTE b = data->palette[i * 3 + 2]; + if ((i & 31) == 0) + off += 2; + valhi = ((r & 0xf0) << 4) | ((g & 0xf0)) | ((b & 0xf0) >> 4); + vallo = ((r & 0x0f) << 8) | ((g & 0x0f) << 4) | ((b & 0x0f)); + data->copper2.copper2_palette[i * 2 + off] = valhi; + data->copper2.copper2_palette_aga_lo[i * 2 + off] = vallo; + if (data->interlace) { + data->copper2i.copper2_palette[i * 2 + off] = valhi; + data->copper2i.copper2_palette_aga_lo[i * 2 + off] = vallo; + } + } + } else if (data->res == 2 && !data->aga) { + /* ECS "scrambled" superhires */ + for (i = 0; i < data->use_colors; i++) { + UBYTE offset = i < 16 ? 0 : 16; + UBYTE c1 = (i & 3) + offset; + UBYTE c2 = ((i >> 2) & 3) + offset; + UWORD val1 = ((data->palette[c1 * 3 + 0] >> 4) << 8) | ((data->palette[c1 * 3 + 1] >> 4) << 4) | ((data->palette[c1 * 3 + 2] >> 4) << 0); + UWORD val2 = ((data->palette[c2 * 3 + 0] >> 4) << 8) | ((data->palette[c2 * 3 + 1] >> 4) << 4) | ((data->palette[c2 * 3 + 2] >> 4) << 0); + UWORD val = (val1 & 0xccc) | ((val2 & 0xccc) >> 2); + data->copper2.copper2_palette[i * 2 + 1] = val; + if (data->interlace) + data->copper2i.copper2_palette[i * 2 + 1] = val; + } + + } else { + for (i = 0; i < data->use_colors; i++) { + UWORD val = ((data->palette[i * 3 + 0] >> 4) << 8) | ((data->palette[i * 3 + 1] >> 4) << 4) | ((data->palette[i * 3 + 2] >> 4) << 0); + data->copper2.copper2_palette[i * 2 + 1] = val; + if (data->interlace) + data->copper2i.copper2_palette[i * 2 + 1] = val; + } + } +} + +static void setpalntsc(struct amigavideo_staticdata *data, ULONG modeid) +{ + volatile struct Custom *custom = (struct Custom*)0xdff000; + struct GfxBase *GfxBase = (APTR)data->cs_GfxBase; + + data->palmode = (GfxBase->DisplayFlags & NTSC) == 0; + if (!data->ecs_agnus) + return; + if ((modeid & MONITOR_ID_MASK) == PAL_MONITOR_ID) { + custom->beamcon0 = 0x0020; + data->palmode = TRUE; + } else if ((modeid & MONITOR_ID_MASK) == NTSC_MONITOR_ID) { + custom->beamcon0 = 0x0000; + data->palmode = FALSE; + } else { + custom->beamcon0 = (GfxBase->DisplayFlags & NTSC) ? 0x0000 : 0x0020; + } +} + +void resetmode(struct amigavideo_staticdata *data) +{ + volatile struct Custom *custom = (struct Custom*)0xdff000; + struct GfxBase *GfxBase = (APTR)data->cs_GfxBase; + + D(bug("resetmode\n")); + + data->disp = NULL; + + custom->dmacon = 0x0100; + setpalntsc(data, 0); + + custom->cop2lc = (ULONG)data->copper2_backup; + custom->copjmp2 = 0; + + waitvblank(data); + + FreeVec(data->copper2.copper2); + data->copper2.copper2 = NULL; + FreeVec(data->copper2i.copper2); + data->copper2i.copper2 = NULL; + + GfxBase->LOFlist = GfxBase->SHFlist = data->copper2_backup; + + resetcustom(data); + + data->depth = 0; +} + +/* Use nominal screen height. Overscan is not supported yet. */ +static WORD limitheight(struct amigavideo_staticdata *data, WORD y, BOOL lace, BOOL maxlimit) +{ + if (lace) + y /= 2; + if (data->palmode) { + if (maxlimit && y > 311) + y = 311; + else if (!maxlimit && y > 256) + y = 256; + } else { + if (maxlimit && y > 261) + y = 261; + else if (!maxlimit && y > 200) + y = 200; + } + if (lace) + y *= 2; + return y; +} + +static void setcopperscroll2(struct amigavideo_staticdata *data, struct amigabm_data *bm, struct copper2data *c2d, BOOL odd) +{ + UWORD *copptr = c2d->copper2_scroll, *copbpl; + WORD xscroll, yscroll; + WORD x, y; + WORD ystart, yend, i, xdelay; + WORD xmaxscroll, modulo, ddfstrt, fmodewidth, minearly; + LONG offset; + + fmodewidth = 16 << data->fmode_bpl; + x = bm->leftedge; + y = data->starty + (bm->topedge >> data->interlace); + + yscroll = 0; + if (y < 10) { + yscroll = y - 10; + y = 10; + } + + xmaxscroll = 1 << (1 + data->fmode_bpl); + xdelay = x & (fmodewidth - 1); + xscroll = -x; + + yend = y + (bm->displayheight >> data->interlace); + yend = limitheight(data, yend, FALSE, TRUE); + ystart = y - data->extralines; + + modulo = (data->interlace ? bm->bytesperrow : 0) + data->modulo; + ddfstrt = data->ddfstrt; + + offset = ((xscroll + (xmaxscroll << 3) - 1) >> 3) & ~(xmaxscroll - 1); + offset -= (yscroll * bm->bytesperrow) << (data->interlace ? 1 : 0); + + minearly = 1 << fetchunits[data->fmode_bpl * 4 + data->res]; + if (xdelay) { + ddfstrt -= minearly; + modulo -= (minearly << data->res) / 4; + offset -= (minearly << data->res) / 4; + } + + copptr[1] = (y << 8) | (data->startx); //(y << 8) + (x + 1); + copptr[3] = (yend << 8) | ((data->startx + 0x140) & 0xff); //((y + (bm->rows >> data->interlace)) << 8) + ((x + 1 + (bm->width >> data->res)) & 0x00ff); + copptr[5] = ((y >> 8) & 7) | (((yend >> 8) & 7) << 8) | 0x2000; + + copbpl = c2d->copper2_bpl; + for (i = 0; i < bm->depth; i++) { + ULONG pptr = (ULONG)(bm->pbm->Planes[data->bploffsets[i]]); + if (data->interlace && odd) + pptr += bm->bytesperrow; + pptr += offset; + copbpl[1] = (UWORD)(pptr >> 16); + copbpl[3] = (UWORD)(pptr >> 0); + copbpl += 4; + } + + xdelay <<= 2 - data->res; + copptr[11] = + (((xdelay >> 2) & 0x0f) << 0) | (((xdelay >> 2) & 0x0f) << 4) + | ((xdelay >> 6) << 10) | ((xdelay >> 6) << 14) + | ((xdelay & 3) << 8) | ((xdelay & 3) << 12); + + copptr[7] = ddfstrt; + copptr[9] = data->ddfstop; + copptr[13] = modulo; + copptr[15] = modulo; + + yend = y + bm->displayheight + yscroll; + yend = limitheight(data, yend, FALSE, TRUE); + copptr = c2d->copper2_bplcon0; + copptr[4] = (yend << 8) | 0x05; + if (yend < 256 || ystart >= 256) { + copptr[2] = 0x00df; + copptr[3] = 0x00fe; + } else { + copptr[2] = 0xffdf; + copptr[3] = 0xfffe; + } + + copptr = c2d->copper2; + if (ystart >= 256) + copptr[0] = 0xffdf; + else + copptr[0] = 0x01fe; + copptr[2] = (ystart << 8) | 0x05; + copptr = c2d->copper2_bplcon0; + copptr[-2] = (y << 8) | 0x05; +} + +static void setcopperscroll(struct amigavideo_staticdata *data, struct amigabm_data *bm) +{ + setcopperscroll2(data, bm, &data->copper2, FALSE); + if (data->interlace) + setcopperscroll2(data, bm, &data->copper2i, TRUE); +} + +static UWORD get_copper_list_length(struct amigavideo_staticdata *data, UBYTE depth) +{ + UWORD v; + + if (data->aga && data->aga_enabled) { + v = 1000 + ((1 << depth) + 1 + (1 << depth) / 32 + 1) * 2; + } else { + v = 1000; + } + return v * 2; +} + +static void createcopperlist(struct amigavideo_staticdata *data, struct amigabm_data *bm, struct copper2data *c2d, BOOL lace) +{ + UWORD *c; + UWORD i; + UWORD bplcon0, bplcon0_res; + ULONG pptr; + + c = c2d->copper2; + D(bug("Copperlist%d %p\n", lace ? 2 : 1, c)); + + if (data->res == 1) + bplcon0_res = 0x8000; + else if (data->res == 2) + bplcon0_res = 0x0040; + else + bplcon0_res = 0; + + data->bplcon0_null = 0x0201 | (data->interlace ? 4 : 0) | bplcon0_res; + data->bplcon3 = ((data->sprite_res + 1) << 6) | 2; // spriteres + bordersprite + + *c++ = 0x01fe; + *c++ = 0xfffe; + *c++ = 0xffff; + *c++ = 0xfffe; + + *c++ = 0x0100; + *c++ = data->bplcon0_null; + + c2d->copper2_bpl = c; + for (i = 0; i < bm->depth; i++) { + pptr = (ULONG)(bm->pbm->Planes[data->bploffsets[i]]); + if (lace) + pptr += bm->bytesperrow; + *c++ = 0xe0 + i * 4; + *c++ = (UWORD)(pptr >> 16); + *c++ = 0xe2 + i * 4; + *c++ = (UWORD)(pptr >> 0); + } + + data->use_colors = 1 << bm->depth; + // need to update sprite colors + if (data->use_colors < 16 + 4) + data->use_colors = 16 + 4; + if (data->res == 2 && !data->aga) + data->use_colors = 32; /* ECS "scrambled" superhires */ + + if (data->use_colors > 32 && (data->modeid & EXTRAHALFBRITE_KEY)) + data->use_colors = 32; + if (data->modeid & HAM_KEY) { + if (bm->depth <= 6) + data->use_colors = 16 + 4; + else + data->use_colors = 64; + } + + c2d->copper2_scroll = c; + *c++ = 0x008e; + *c++ = 0; + *c++ = 0x0090; + *c++ = 0; + *c++ = 0x01e4; + *c++ = 0; + *c++ = 0x0092; + *c++ = 0; + *c++ = 0x0094; + *c++ = 0; + *c++ = 0x0102; + *c++ = 0; + *c++ = 0x0108; + *c++ = 0; + *c++ = 0x010a; + *c++ = 0; + *c++ = 0x0104; + *c++ = 0x0024 | ((data->aga && !(data->modeid & EXTRAHALFBRITE_KEY)) ? 0x0200 : 0); + + c2d->copper2_fmode = NULL; + if (data->aga && data->aga_enabled) { + *c++ = 0x010c; + *c++ = 0x0011; + *c++ = 0x01fc; + c2d->copper2_fmode = c; + *c++ = 0; + } + + bplcon0 = data->bplcon0_null; + if (bm->depth > 7) + bplcon0 |= 0x0010; + else + bplcon0 |= bm->depth << 12; + if (data->modeid & HAM_KEY) + bplcon0 |= 0x0800; + + c2d->copper2_palette = c; + if (data->aga && data->aga_enabled) { + // hi + for (i = 0; i < data->use_colors; i++) { + UBYTE agac = i & 31; + if (agac == 0) { + *c++ = 0x106; + *c++ = data->bplcon3 | ((i / 32) << 13); + } + *c++ = 0x180 + agac * 2; + *c++ = 0x000; + } + c2d->copper2_palette_aga_lo = c; + // lo + for (i = 0; i < data->use_colors; i++) { + UBYTE agac = i & 31; + if (agac == 0) { + *c++ = 0x106; + *c++ = data->bplcon3 | ((i / 32) << 13) | 0x0200; + } + *c++ = 0x180 + agac * 2; + *c++ = 0x000; + } + *c++ = 0x106; + *c++ = data->bplcon3; + } else { + // ocs/ecs + for (i = 0; i < data->use_colors; i++) { + *c++ = 0x180 + i * 2; + *c++ = 0x000; + } + } + + data->extralines = (c - c2d->copper2) / 112 + 1; + + *c++ = 0xffff; + *c++ = 0xfffe; + c2d->copper2_bplcon0 = c; + *c++ = 0x0100; + *c++ = bplcon0; + + *c++ = 0xffff; + *c++ = 0xfffe; + *c++ = 0xffff; + *c++ = 0xfffe; + + *c++ = 0x0100; + *c++ = data->bplcon0_null; + + if (data->interlace) { + ULONG nextptr = (ULONG)(lace ? data->copper2.copper2 : data->copper2i.copper2); + *c++ = 0x0084; + *c++ = (UWORD)(nextptr >> 16); + *c++ = 0x0086; + *c++ = (UWORD)(nextptr >> 0); + } + *c++ = 0xffff; + *c++ = 0xfffe; + +} + +BOOL setbitmap(struct amigavideo_staticdata *data, struct amigabm_data *bm) +{ + data->width = bm->width; + data->height = data->interlace ? (bm->height + 1) / 2 : bm->height; + data->modulo = bm->bytesperrow - data->modulopre / (4 >> data->res); + data->modulo &= ~((2 << data->fmode_bpl) - 1); + data->updatescroll = bm; + data->depth = bm->depth; + setcopperscroll(data, bm); + + D(bug("setbitmap bm=%x mode=%08x w=%d h=%d d=%d bpr=%d\n", + bm, data->modeid, bm->width, bm->height, bm->depth, bm->bytesperrow)); + return TRUE; +} + +BOOL setmode(struct amigavideo_staticdata *data, struct amigabm_data *bm) +{ + volatile struct Custom *custom = (struct Custom*)0xdff000; + struct GfxBase *GfxBase = (APTR)data->cs_GfxBase; + UWORD ddfstrt, ddfstop; + UBYTE fetchunit, maxplanes; + UWORD bplwidth, viewwidth; + UBYTE i; + + if (data->disp == bm) + return TRUE; + + resetmode(data); + + data->res = 0; + if ((data->modeid & SUPER_KEY) == SUPER_KEY) + data->res = 2; + else if ((data->modeid & SUPER_KEY) == HIRES_KEY) + data->res = 1; + data->interlace = (data->modeid & LORESLACE_KEY) ? 1 : 0; + data->fmode_bpl = data->aga && data->aga_enabled ? 2 : 0; + + fetchunit = fetchunits[data->fmode_bpl * 4 + data->res]; + maxplanes = fm_maxplanes[data->fmode_bpl * 4 + data->res]; + + D(bug("res %d fmode %d depth %d maxplanes %d aga %d agae %d\n", + data->res, data->fmode_bpl, bm->depth, maxplanes, data->aga, data->aga_enabled)); + + if (bm->depth > (1 << maxplanes)) { + if (data->aga && !data->aga_enabled) { + // Enable AGA if requesting AGA only mode. + // This is a compatibility hack because our display + // database currently contains all AGA modes even if AGA + // is "disabled". + GfxBase->ChipRevBits0 = SETCHIPREV_AA; + data->aga_enabled = TRUE; + data->fmode_bpl = data->aga && data->aga_enabled ? 2 : 0; + fetchunit = fetchunits[data->fmode_bpl * 4 + data->res]; + maxplanes = fm_maxplanes[data->fmode_bpl * 4 + data->res]; + } + if (bm->depth > (1 << maxplanes)) + return FALSE; + } + + viewwidth = bm->width; + // use nominal width for now + if ((viewwidth << data->res) > 320) + viewwidth = 320 << data->res; + + D(bug("setmode bm=%x mode=%08x w=%d h=%d d=%d bpr=%d fu=%d\n", + bm, data->modeid, bm->width, bm->height, bm->depth, bm->bytesperrow, fetchunit)); + + bplwidth = viewwidth >> (data->res + 1); + ddfstrt = (data->startx / 2) & ~((1 << fetchunit) - 1); + ddfstop = ddfstrt + ((bplwidth + ((1 << fetchunit) - 1) - 2 * (1 << fetchunit)) & ~((1 << fetchunit) - 1)); + data->modulopre = ddfstop + 2 * (1 << fetchunit) - ddfstrt; + ddfstrt -= 1 << maxplanes; + data->ddfstrt = ddfstrt; + data->ddfstop = ddfstop; + + for (i = 0; i < 8; i++) + data->bploffsets[i] = i; + if ((data->modeid & HAM_KEY) && bm->depth > 6) { + data->bploffsets[0] = 6; + data->bploffsets[1] = 7; + for (i = 0; i < 6; i++) + data->bploffsets[i + 2] = i; + } + + data->copper2.copper2 = AllocVec(get_copper_list_length(data, bm->depth), MEMF_CLEAR | MEMF_CHIP); + if (data->interlace) + data->copper2i.copper2 = AllocVec(get_copper_list_length(data, bm->depth), MEMF_CLEAR | MEMF_CHIP); + createcopperlist(data, bm, &data->copper2, FALSE); + if (data->interlace) { + createcopperlist(data, bm, &data->copper2i, TRUE); + } + + setfmode(data); + setpalntsc(data, data->modeid); + custom->bplcon0 = data->bplcon0_null; + + bm->displaywidth = viewwidth; + bm->displayheight = limitheight(data, bm->height, data->interlace, FALSE); + + setbitmap(data, bm); + + GfxBase->LOFlist = data->copper2.copper2; + GfxBase->SHFlist = data->interlace ? data->copper2i.copper2 : data->copper2.copper2; + custom->dmacon = 0x8100; + + setcoppercolors(data); + setspritepos(data, data->spritex, data->spritey); + + data->disp = bm; + return 1; + } + +BOOL setsprite(struct amigavideo_staticdata *data, WORD width, WORD height, struct pHidd_Gfx_SetCursorShape *shape) +{ + OOP_MethodID HiddBitMapBase = data->cs_HiddBitMapBase; + UWORD fetchsize; + UWORD bitmapwidth = width; + UWORD y, *p; + + if (data->aga && data->aga_enabled && width > 16) + data->fmode_spr = 2; + else + data->fmode_spr = 0; + fetchsize = 2 << data->fmode_spr; + width = 16 << data->fmode_spr; + + if (width != data->sprite_width || height != data->sprite_height) { + resetsprite(data); + data->spritedatasize = fetchsize * 2 + fetchsize * height * 2 + fetchsize * 2; + data->sprite = AllocMem(data->spritedatasize, MEMF_CHIP | MEMF_CLEAR); + if (!data->sprite) + return FALSE; + data->sprite_width = width; + data->sprite_height = height; + data->sprite_offset_x = shape->xoffset; + data->sprite_offset_y = shape->yoffset; + } + p = data->sprite; + p += fetchsize; + for(y = 0; y < height; y++) { + UWORD xx, xxx, x; + for (xx = 0, xxx = 0; xx < width; xx += 16, xxx++) { + UWORD pix1 = 0, pix2 = 0; + for(x = 0; x < 16; x++) { + UBYTE c = 0; + if (xx + x < bitmapwidth) + c = HIDD_BM_GetPixel(shape->shape, xx + x, y); +#if 0 + /* Sprite alignment grid */ + if (xx + x == 0 || xx + x == width - 1 || y == 0 || y == height - 1) { + c = 2; + } else if (0) { + c = 0; + } +#endif + pix1 <<= 1; + pix2 <<= 1; + pix1 |= (c & 1) ? 1 : 0; + pix2 |= (c & 2) ? 1 : 0; + } + p[xxx] = pix1; + p[xxx + fetchsize / 2] = pix2; + } + p += fetchsize; + } + setspritepos(data, data->spritex, data->spritey); + setspritevisible(data, data->cursorvisible); + return TRUE; +} + +void setspritepos(struct amigavideo_staticdata *data, WORD x, WORD y) +{ + UWORD ctl, pos; + + data->spritex = x; + data->spritey = y; + if (!data->sprite || data->sprite_height == 0) + return; + + x += data->sprite_offset_x << data->res; + x <<= (2 - data->res); // convert x to shres coordinates + x += (data->startx - 1) << 2; // display left edge offset + + if (data->interlace) + y /= 2; // y is always in nonlaced + y += data->starty; + y += data->sprite_offset_y; + + pos = (y << 8) | (x >> 3); + ctl = ((y + data->sprite_height) << 8); + ctl |= ((y >> 8) << 2) | (((y + data->sprite_height) >> 8) << 1) | ((x >> 2) & 1) | ((x & 3) << 3); + data->spritepos = pos; + data->spritectl = ctl; +} + +void setspritevisible(struct amigavideo_staticdata *data, BOOL visible) +{ + data->cursorvisible = visible; + if (visible) { + if (data->copper1_spritept) { + UWORD *p = data->sprite; + setfmode(data); + data->copper1_spritept[0] = (UWORD)(((ULONG)p) >> 16); + data->copper1_spritept[2] = (UWORD)(((ULONG)p) >> 0); +} + } else { + setnullsprite(data); + } +} + +BOOL setcolors(struct amigavideo_staticdata *data, struct pHidd_BitMap_SetColors *msg, BOOL visible) +{ + UWORD i, j; + if (msg->firstColor + msg->numColors > data->max_colors) + return FALSE; + j = 0; + for (i = msg->firstColor; j < msg->numColors; i++, j++) { + UBYTE red, green, blue; + red = msg->colors[j].red >> 8; + green = msg->colors[j].green >> 8; + blue = msg->colors[j].blue >> 8; + data->palette[i * 3 + 0] = red; + data->palette[i * 3 + 1] = green; + data->palette[i * 3 + 2] = blue; + //bug("%d: %02x %02x %02x\n", i, red, green, blue); + } + if (visible) + setcoppercolors(data); + return TRUE; +} +void setscroll(struct amigavideo_staticdata *data, struct amigabm_data *bm) +{ + data->updatescroll = bm; +} + +/* Convert Z flag to normal C-style return variable. Fun. */ +UBYTE bltnode_wrapper(void) +{ + UBYTE ret; + asm volatile ( + " pea 1f\n" + " move.l 4(%%a1),-(%%sp)\n" + " rts\n" + "1: sne %d0\n" + " move.b %%d0,%0\n" + : "=g" (ret) + ); + return ret; +} + +#define BEAMSYNC_ALARM 0x0f00 +/* AOS must use some GfxBase flags field for these. Later.. */ +#define bqvar GfxBase->pad3 +#define BQ_NEXT 1 +#define BQ_BEAMSYNC 2 +#define BQ_BEAMSYNCWAITING 4 +#define BQ_MISSED 8 + +static AROS_INTH1(gfx_blit, struct GfxBase *, GfxBase) +{ + AROS_INTFUNC_INIT + + volatile struct Custom *custom = (struct Custom*)0xdff000; + struct bltnode *bn = NULL; + UBYTE v; + UWORD dmaconr; + + dmaconr = custom->dmaconr; + dmaconr = custom->dmaconr; + if (dmaconr & 0x4000) { + /* Blitter still active? Wait for next interrupt. */ + return 0; + } + + if (GfxBase->blthd == NULL && GfxBase->bsblthd == NULL) { + custom->intena = INTF_BLIT; + return 0; + } + + /* Was last blit in this node? */ + if (bqvar & BQ_NEXT) { + bqvar &= ~(BQ_NEXT | BQ_MISSED); + if (bqvar & BQ_BEAMSYNC) + bn = GfxBase->bsblthd; + else + bn = GfxBase->blthd; + if (bn->stat == CLEANUP) + AROS_UFC2(UBYTE, bn->cleanup, + AROS_UFCA(struct Custom *, custom, A0), + AROS_UFCA(struct bltnode*, bn, A1)); + /* Next node */ + bn = bn->n; + if (bqvar & BQ_BEAMSYNC) + GfxBase->bsblthd = bn; + else + GfxBase->blthd = bn; + } + + if (GfxBase->bsblthd) { + bn = GfxBase->bsblthd; + bqvar |= BQ_BEAMSYNC; + } else if (GfxBase->blthd) { + bn = GfxBase->blthd; + bqvar &= ~BQ_BEAMSYNC; + } + + if (!bn) { + /* Last blit finished */ + bqvar = 0; + custom->intena = INTF_BLIT; + GfxBase->blthd = GfxBase->bsblthd = NULL; + DisownBlitter(); + return 0; + } + + if (bqvar & BQ_BEAMSYNC) { + UWORD vpos = VBeamPos(); + bqvar &= ~BQ_BEAMSYNCWAITING; + if (!(bqvar & BQ_MISSED) && bn->beamsync > vpos) { + volatile struct CIA *ciab = (struct CIA*)0xbfd000; + UWORD w = BEAMSYNC_ALARM - (bn->beamsync - vpos); + bqvar |= BQ_BEAMSYNCWAITING; + ciab->ciacrb &= ~0x80; + ciab->ciatodhi = 0; + ciab->ciatodmid = w >> 8; + ciab->ciatodlow = w; + return 0; + } + } + + v = AROS_UFC2(UBYTE, bltnode_wrapper, + AROS_UFCA(struct Custom *, custom, A0), + AROS_UFCA(struct bltnode*, bn, A1)); + + dmaconr = custom->dmaconr; + dmaconr = custom->dmaconr; + if (!(dmaconr & 0x4000)) { + /* Eh? Blitter not active?, better fake the interrupt. */ + custom->intreq = INTF_SETCLR | INTF_BLIT; + } + + if (v) { + /* Handle same node again next time */ + return 0; + } + + bqvar |= BQ_NEXT; + + return 0; + + AROS_INTFUNC_EXIT +} + +static AROS_INTH1(gfx_beamsync, struct amigavideo_staticdata*, data) +{ + AROS_INTFUNC_INIT + + struct GfxBase *GfxBase = (APTR)data->cs_GfxBase; + + if (bqvar & BQ_BEAMSYNCWAITING) { + /* We only need to trigger blitter interrupt */ + volatile struct Custom *custom = (struct Custom*)0xdff000; + custom->intreq = INTF_SETCLR | INTF_BLIT; + } + + return FALSE; + + AROS_INTFUNC_EXIT +} + +static AROS_INTH1(gfx_vblank, struct amigavideo_staticdata*, data) +{ + AROS_INTFUNC_INIT + + struct GfxBase *GfxBase = (APTR)data->cs_GfxBase; + volatile struct Custom *custom = (struct Custom*)0xdff000; + BOOL lof = (custom->vposr & 0x8000) != 0; + + if (data->interlace) { + custom->cop2lc = (ULONG)(lof ? GfxBase->LOFlist : GfxBase->SHFlist); + } else { + custom->cop2lc = (ULONG)GfxBase->LOFlist; + /* We may be in SHF mode after switching interlace off. Fix it here. */ + if (!lof) + custom->vposw = custom->vposr | 0x8000; + } + + data->framecounter++; + if (data->sprite) { + UWORD *p = data->sprite; + p[0] = data->spritepos; + p[1 << data->fmode_spr] = data->spritectl; + } + + if (data->updatescroll) { + setcopperscroll(data, data->updatescroll); + data->updatescroll = NULL; + } + + if (bqvar & BQ_BEAMSYNC) + bqvar |= BQ_MISSED; + + return FALSE; + + AROS_INTFUNC_EXIT +} + +void initcustom(struct amigavideo_staticdata *data) +{ + UBYTE i; + UWORD *c; + UWORD vposr, val; + struct GfxBase *GfxBase; + struct Library *OOPBase; + volatile struct Custom *custom = (struct Custom*)0xdff000; + volatile struct CIA *ciab = (struct CIA*)0xbfd000; + + /* Reset audio registers to values that help emulation + * if some program enables audio DMA without setting period + * or length. Very high period emulation is very CPU intensive. + */ + for (i = 0; i < 4; i++) { + custom->aud[i].ac_vol = 0; + custom->aud[i].ac_per = 100; + custom->aud[i].ac_len = 1000; + } + + resetcustom(data); + resetsprite(data); + + /* data->cs_OOPBase was already set up. + * See amigavideo.conf's 'oopbase_field' config + */ + OOPBase = data->cs_OOPBase; + data->cs_HiddBitMapBase = OOP_GetMethodID(IID_Hidd_BitMap, 0); + data->cs_HiddGfxBase = OOP_GetMethodID(IID_Hidd_Gfx, 0); + + data->cs_UtilityBase = TaggedOpenLibrary(TAGGEDOPEN_UTILITY); + if (!data->cs_UtilityBase) + Alert(AT_DeadEnd | AN_Hidd | AG_OpenLib | AO_UtilityLib); + data->cs_GfxBase = TaggedOpenLibrary(TAGGEDOPEN_GRAPHICS); + if (!data->cs_GfxBase) + Alert(AT_DeadEnd | AN_Hidd | AG_OpenLib | AO_GraphicsLib); + GfxBase = ((struct GfxBase *)data->cs_GfxBase); + GfxBase->cia = OpenResource("ciab.resource"); + + data->inter.is_Code = (APTR)gfx_vblank; + data->inter.is_Data = data; + data->inter.is_Node.ln_Name = "GFX VBlank server"; + data->inter.is_Node.ln_Pri = 25; + data->inter.is_Node.ln_Type = NT_INTERRUPT; + AddIntServer(INTB_VERTB, &data->inter); + + /* There are programs that take over the system and + * assume SysBase->IntVects[BLITTER].iv_Data = GfxBase! + */ + GfxBase->bltsrv.is_Code = (APTR)gfx_blit; + GfxBase->bltsrv.is_Data = GfxBase; + GfxBase->bltsrv.is_Node.ln_Name = "Blitter"; + GfxBase->bltsrv.is_Node.ln_Type = NT_INTERRUPT; + SetIntVector(INTB_BLIT, &GfxBase->bltsrv); + custom->intena = INTF_BLIT; + + // CIA-B TOD counts scanlines */ + GfxBase->timsrv.is_Code = (APTR)gfx_beamsync; + GfxBase->timsrv.is_Data = data; + GfxBase->timsrv.is_Node.ln_Name = "Beamsync"; + GfxBase->timsrv.is_Node.ln_Type = NT_INTERRUPT; + Disable(); + AddICRVector(GfxBase->cia, 2, &GfxBase->timsrv); + AbleICR(GfxBase->cia, 1 << 2); + ciab->ciacrb |= 0x80; + ciab->ciatodhi = 0; + /* TOD/ALARM CIA bug: http://eab.abime.net/showpost.php?p=277315&postcount=10 */ + ciab->ciatodmid = BEAMSYNC_ALARM >> 8; + ciab->ciatodlow = BEAMSYNC_ALARM & 0xff; + ciab->ciacrb &= ~0x80; + ciab->ciatodhi = 0; + ciab->ciatodmid = 0; + ciab->ciatodlow = 0; + AbleICR(GfxBase->cia, 0x80 | (1 << 2)); + Enable(); + + GfxBase->NormalDisplayColumns = 640; + GfxBase->NormalDisplayRows = (GfxBase->DisplayFlags & NTSC) ? 200 : 256; + GfxBase->MaxDisplayColumn = 640; + GfxBase->MaxDisplayRow = (GfxBase->DisplayFlags & NTSC) ? 200 : 256; + + data->startx = 0x81; + data->starty = 0x28; + + vposr = custom->vposr & 0x7f00; + data->aga = vposr >= 0x2200; + data->ecs_agnus = vposr >= 0x2000; + val = custom->deniseid; + custom->deniseid = custom->dmaconr;; + if (val == custom->deniseid) { + custom->deniseid = custom->dmaconr ^ 0x8000; + if (val == custom->deniseid) { + if ((val & (2 + 8)) == 8) + data->ecs_denise = TRUE; + } + } + data->max_colors = data->aga ? 256 : 32; + data->palette = AllocVec(data->max_colors * 3, MEMF_CLEAR); + data->copper1 = AllocVec(22 * 2 * sizeof(WORD), MEMF_CLEAR | MEMF_CHIP); + data->sprite_null = AllocMem(2 * 8, MEMF_CLEAR | MEMF_CHIP); + data->sprite_res = 0; /* lores */ + c = data->copper1; + for (i = 0; i < 8; i++) { + *c++ = 0x0120 + i * 4; + if (i == 0) + data->copper1_spritept = c; + *c++ = (UWORD)(((ULONG)data->sprite_null) >> 16); + *c++ = 0x0122 + i * 4; + *c++ = (UWORD)(((ULONG)data->sprite_null) >> 0); + } + *c++ = 0x0c03; + *c++ = 0xfffe; + *c++ = 0x008a; + *c++ = 0x0000; + data->copper2_backup = c; + *c++ = 0xffff; + *c++ = 0xfffe; + custom->cop1lc = (ULONG)data->copper1; + custom->cop2lc = (ULONG)data->copper2_backup; + custom->dmacon = 0x8000 | 0x0080 | 0x0040 | 0x0020; + + GfxBase->copinit = (struct copinit*)data->copper1; + + D(bug("Copperlist0 %p\n", data->copper1)); + +} diff --git a/arch/m68k-amiga/hidd/amigavideo/chipset.h b/arch/m68k-amiga/hidd/amigavideo/chipset.h index fe4b2aa380..0654da05e2 100644 --- a/arch/m68k-amiga/hidd/amigavideo/chipset.h +++ b/arch/m68k-amiga/hidd/amigavideo/chipset.h @@ -10,7 +10,7 @@ BOOL setbitmap(struct amigavideo_staticdata *data, struct amigabm_data*); void initcustom(struct amigavideo_staticdata *data); void setspritepos(struct amigavideo_staticdata *data, WORD x, WORD y); -BOOL setsprite(OOP_Class *cl, OOP_Object *o, WORD w, WORD h, struct pHidd_Gfx_SetCursorShape *shape); +BOOL setsprite(struct amigavideo_staticdata *data, WORD w, WORD h, struct pHidd_Gfx_SetCursorShape *shape); void resetsprite(struct amigavideo_staticdata *data); void setspritevisible(struct amigavideo_staticdata *data, BOOL visible); diff --git a/arch/m68k-amiga/hidd/amigavideo/mmakefile.src b/arch/m68k-amiga/hidd/amigavideo/mmakefile.src index 9aa33c7509..2e5a34d56b 100644 --- a/arch/m68k-amiga/hidd/amigavideo/mmakefile.src +++ b/arch/m68k-amiga/hidd/amigavideo/mmakefile.src @@ -8,8 +8,7 @@ USER_CPPFLAGS += \ -D__OOP_NOLIBBASE__ \ -D__GRAPHICS_NOLIBBASE__ \ -D__UTILITY_NOLIBBASE__ \ - -D__GRAPHICS_NOHIDDBASE__ -#USER_CPPFLAGS += -DDEBUG=1 + -D__GRAPHICS_ %build_module mmake=kernel-amiga-m68k-amigavideo \ modname=amigavideo modtype=hidd \ diff --git a/arch/m68k-amiga/hidd/amigavideo/startup.c b/arch/m68k-amiga/hidd/amigavideo/startup.c index ad5fc9aa77..432f8ec040 100644 --- a/arch/m68k-amiga/hidd/amigavideo/startup.c +++ b/arch/m68k-amiga/hidd/amigavideo/startup.c @@ -1,8 +1,10 @@ /* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. + Copyright © 1995-2017, The AROS Development Team. All rights reserved. $Id$ */ +#define DEBUG 0 + #include #include #include @@ -23,19 +25,15 @@ int Init_AmigaVideoClass(LIBBASETYPEPTR LIBBASE); static int AmigaVideo_Init(LIBBASETYPEPTR LIBBASE) { ULONG err; - struct Library *GfxBase, *OOPBase = LIBBASE->csd.cs_OOPBase; + struct Library *GfxBase, *OOPBase; - D( - bug("[AmigaVideo] %s() *****************************\n", __func__); - bug("[AmigaVideo] %s: libbase @ 0x%p\n", __func__, LIBBASE); - bug("[AmigaVideo] %s: csd @ 0x%p\n", __func__, &LIBBASE->csd); - bug("[AmigaVideo] %s: OOPBase @ 0x%p\n", __func__, OOPBase); - ) + + D(bug("************************* AmigaVideo_Init ******************************\n")); initcustom(&LIBBASE->csd); GfxBase = LIBBASE->csd.cs_GfxBase; - - D(bug("[AmigaVideo] %s: GfxBase @ 0x%p\n", __func__, GfxBase);) + + OOPBase = OpenLibrary("oop.library", 0); LIBBASE->csd.cs_basebm = OOP_FindClass(CLID_Hidd_BitMap); @@ -48,8 +46,9 @@ static int AmigaVideo_Init(LIBBASETYPEPTR LIBBASE) DDRV_IDMask , 0xF0000000, TAG_DONE); - D(bug("[AmigaVideo] %s: AddDisplayDriver() result: %u\n", __func__, err);) + CloseLibrary(OOPBase); + D(bug("AMIGAGFXHIDD AddDisplayDriver() result: %u\n", err)); return err ? FALSE : TRUE; } diff --git a/arch/m68k-amiga/hidd/gayle_ata/bus_class.h b/arch/m68k-amiga/hidd/gayle_ata/bus_class.h index e2e1def4e6..8517d8c8e0 100644 --- a/arch/m68k-amiga/hidd/gayle_ata/bus_class.h +++ b/arch/m68k-amiga/hidd/gayle_ata/bus_class.h @@ -35,7 +35,6 @@ struct ataBase OOP_Object *storageRoot; OOP_AttrBase hiddAttrBase; - OOP_AttrBase busAttrBase; OOP_AttrBase ATABusAttrBase; OOP_AttrBase hwAttrBase; @@ -47,11 +46,9 @@ struct ataBase }; #undef HiddAttrBase -#undef HiddBusAB #undef HiddATABusAB #undef HWAttrBase #define HiddAttrBase (base->hiddAttrBase) -#define HiddBusAB (base->busAttrBase) #define HiddATABusAB (base->ATABusAttrBase) #define HWAttrBase (base->hwAttrBase) diff --git a/arch/m68k-amiga/hidd/gayle_ata/class_init.c b/arch/m68k-amiga/hidd/gayle_ata/class_init.c index e593b8e07c..eaf2bd3183 100644 --- a/arch/m68k-amiga/hidd/gayle_ata/class_init.c +++ b/arch/m68k-amiga/hidd/gayle_ata/class_init.c @@ -1,5 +1,5 @@ /* - Copyright © 2013-2019, The AROS Development Team. All rights reserved + Copyright © 2013-2018, The AROS Development Team. All rights reserved $Id$ Desc: A600/A1200/A4000 ATA HIDD @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -21,35 +20,26 @@ static void GayleATA_Cleanup(struct ataBase *base) { - D(bug("[ATA:Gayle] %s()\n", __func__);) + D(bug("[ATA:Gayle] %s()\n", __PRETTY_FUNCTION__);) OOP_ReleaseAttrBase(HiddAttrBase); OOP_ReleaseAttrBase(HiddATABusAB); - OOP_ReleaseAttrBase(HiddBusAB); OOP_ReleaseAttrBase(HWAttrBase); CloseLibrary(base->cs_UtilityBase); } static int GayleATA_Init(struct ataBase *base) { - D(bug("[ATA:Gayle] %s()\n", __func__);) + D(bug("[ATA:Gayle] %s()\n", __PRETTY_FUNCTION__);) base->cs_UtilityBase = OpenLibrary("utility.library", 36); if (!base->cs_UtilityBase) return FALSE; HiddAttrBase = OOP_ObtainAttrBase(IID_Hidd); - D(bug("[ATA:Gayle] %s: %s AB %x @ 0x%p\n", __func__, IID_Hidd, HiddAttrBase, &HiddAttrBase);) - - HiddBusAB = OOP_ObtainAttrBase(IID_Hidd_Bus); - D(bug("[ATA:Gayle] %s: %s AB %x @ 0x%p\n", __func__, IID_Hidd_Bus, HiddBusAB, &HiddBusAB);) - HiddATABusAB = OOP_ObtainAttrBase(IID_Hidd_ATABus); - D(bug("[ATA:Gayle] %s: %s AB %x @ 0x%p\n", __func__, IID_Hidd_ATABus, HiddATABusAB, &HiddATABusAB);) - HWAttrBase = OOP_ObtainAttrBase(IID_HW); - D(bug("[ATA:Gayle] %s: %s AB %x @ 0x%p\n", __func__, IID_HW, HWAttrBase, &HWAttrBase);) - if (!HiddAttrBase || !HiddBusAB || !HiddATABusAB || !HWAttrBase) + if (!HiddAttrBase || !HiddATABusAB || !HWAttrBase) return FALSE; HWBase = OOP_GetMethodID(IID_HW, 0); @@ -64,17 +54,17 @@ static int GayleATA_Init(struct ataBase *base) return FALSE; } - D(bug("[ATA:Gayle] %s: storage root @ 0x%p\n", __func__, base->storageRoot);) + D(bug("[ATA:Gayle] %s: storage root @ 0x%p\n", __PRETTY_FUNCTION__, base->storageRoot);) base->ataClass = OOP_FindClass(CLID_Hidd_ATA); - D(bug("[ATA:Gayle] %s: %s @ 0x%p\n", __func__, CLID_Hidd_ATA, base->ataClass);) + D(bug("[ATA:Gayle] %s: %s @ 0x%p\n", __PRETTY_FUNCTION__, CLID_Hidd_ATA, base->ataClass);) return TRUE; } static int GayleATA_Expunge(struct ataBase *base) { - D(bug("[ATA:Gayle] %s()\n", __func__);) + D(bug("[ATA:Gayle] %s()\n", __PRETTY_FUNCTION__);) GayleATA_Cleanup(base); diff --git a/arch/m68k-amiga/hidd/gayle_ata/fastata_busclass.c b/arch/m68k-amiga/hidd/gayle_ata/fastata_busclass.c index 9ad7d87af1..7359da2ada 100644 --- a/arch/m68k-amiga/hidd/gayle_ata/fastata_busclass.c +++ b/arch/m68k-amiga/hidd/gayle_ata/fastata_busclass.c @@ -1,5 +1,5 @@ /* - Copyright © 2017-2019, The AROS Development Team. All rights reserved. + Copyright © 2017-2018, The AROS Development Team. All rights reserved. $Id$ Desc: Elbox FastATA HIDD @@ -10,7 +10,6 @@ #include #include -#include #include #include #include @@ -119,13 +118,13 @@ void FASTATA__Root__Set(OOP_Class *cl, OOP_Object *o, struct pRoot_Set *msg) { ULONG idx; - Hidd_Bus_Switch(tag->ti_Tag, idx) + Hidd_ATABus_Switch(tag->ti_Tag, idx) { - case aoHidd_Bus_IRQHandler: + case aoHidd_ATABus_IRQHandler: data->ata_HandleIRQ = (APTR)tag->ti_Data; break; - case aoHidd_Bus_IRQData: + case aoHidd_ATABus_IRQData: data->irqData = (APTR)tag->ti_Data; break; } diff --git a/arch/m68k-amiga/hidd/gayle_ata/gayleata_busclass.c b/arch/m68k-amiga/hidd/gayle_ata/gayleata_busclass.c index 3e48f7ee92..89ff46a945 100644 --- a/arch/m68k-amiga/hidd/gayle_ata/gayleata_busclass.c +++ b/arch/m68k-amiga/hidd/gayle_ata/gayleata_busclass.c @@ -1,5 +1,5 @@ /* - Copyright © 2013-2019, The AROS Development Team. All rights reserved. + Copyright © 2013-2017, The AROS Development Team. All rights reserved. $Id$ Desc: A600/A1200/A4000 ATA HIDD @@ -10,7 +10,6 @@ #include #include -#include #include #include #include @@ -103,7 +102,6 @@ static BOOL ata_CreateGayleInterrupt(struct ATA_BusData *bus, UBYTE num) return TRUE; } - static void ata_RemoveGayleInterrupt(struct ATA_BusData *bus) { struct Interrupt *irq = &bus->ideint; @@ -137,8 +135,6 @@ OOP_Object *GAYLEATA__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New * //OOP_MethodID mDispose; data->bus = bus; - /* Signal structure ownership */ - data->bus->atapb_Node.ln_Succ = (struct Node *)-1; data->gaylebase = data->bus->port; data->gayleirqbase = data->bus->gayleirqbase; ata_CreateGayleInterrupt(data, 0); @@ -202,35 +198,32 @@ void GAYLEATA__Root__Set(OOP_Class *cl, OOP_Object *o, struct pRoot_Set *msg) { ULONG idx; - Hidd_Bus_Switch(tag->ti_Tag, idx) + Hidd_ATABus_Switch(tag->ti_Tag, idx) { - case aoHidd_Bus_IRQHandler: + case aoHidd_ATABus_IRQHandler: data->ata_HandleIRQ = (APTR)tag->ti_Data; break; - case aoHidd_Bus_IRQData: + case aoHidd_ATABus_IRQData: data->irqData = (APTR)tag->ti_Data; break; } } - - OOP_DoSuperMethod(cl, o, &msg->mID); } APTR GAYLEATA__Hidd_ATABus__GetPIOInterface(OOP_Class *cl, OOP_Object *o, OOP_Msg msg) { struct ATA_BusData *data = OOP_INST_DATA(cl, o); - struct pio_data *pio; - + struct pio_data *pio = (struct pio_data *)OOP_DoSuperMethod(cl, o, msg); + D(bug("[ATA:Gayle] %s()\n", __func__);) - pio = (struct pio_data *)OOP_DoSuperMethod(cl, o, msg); if (pio) { pio->port = data->bus->port; pio->altport = data->bus->altport; pio->dataport = (UBYTE*)(((ULONG)pio->port) & ~3); - } + } return pio; } diff --git a/arch/m68k-amiga/hidd/gayle_ata/probe.c b/arch/m68k-amiga/hidd/gayle_ata/probe.c index bd581e82f2..e44c248e8e 100644 --- a/arch/m68k-amiga/hidd/gayle_ata/probe.c +++ b/arch/m68k-amiga/hidd/gayle_ata/probe.c @@ -209,7 +209,7 @@ static int gayle_bus_Scan(struct ataBase *base) {aHidd_ATABus_PIODataSize , sizeof(struct pio_data) }, {aHidd_ATABus_BusVectors , (IPTR)bus_FuncTable }, {aHidd_ATABus_PIOVectors , (IPTR)pio_FuncTable }, - {aHidd_Bus_KeepEmpty , FALSE }, + {aHidd_ATABus_KeepEmpty , FALSE }, {TAG_DONE , 0 } }; OOP_Object *bus; diff --git a/arch/m68k-amiga/hidd/keyboard/amigakbd.conf b/arch/m68k-amiga/hidd/keyboard/amigakbd.conf index be6245c9f5..39d6987e83 100644 --- a/arch/m68k-amiga/hidd/keyboard/amigakbd.conf +++ b/arch/m68k-amiga/hidd/keyboard/amigakbd.conf @@ -1,7 +1,7 @@ ##begin config basename AmigaKbd libbasetype struct kbdbase -version 1.1 +version 1.0 residentpri 40 classid CLID_Hidd_HwKbd superclass CLID_Hidd diff --git a/arch/m68k-amiga/hidd/keyboard/kbd_init.c b/arch/m68k-amiga/hidd/keyboard/kbd_init.c dissimilarity index 89% index 0cc7a8b3ce..9dc112279a 100644 --- a/arch/m68k-amiga/hidd/keyboard/kbd_init.c +++ b/arch/m68k-amiga/hidd/keyboard/kbd_init.c @@ -1,71 +1,32 @@ -/* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#define DEBUG 0 -#include - -#include -#include - -#include -#include - -#include "kbd.h" - -#undef XSD -#define XSD(cl) ksd - -static int AmigaKbd_Init(struct kbdbase *LIBBASE) -{ - struct kbd_staticdata *ksd = &LIBBASE->ksd; - struct OOP_ABDescr attrbases[] = - { - {IID_Hidd , &HiddAttrBase }, - {IID_Hidd_Kbd , &HiddKbdAB }, - {NULL , NULL } - }; - OOP_Object *kbd; - OOP_Object *drv = NULL; - - EnterFunc(bug("AmigaKbd_Init\n")); - - InitSemaphore( &ksd->sema ); - - kbd = OOP_NewObject(NULL, CLID_Hidd_Kbd, NULL); - if (kbd) { - if (OOP_ObtainAttrBases(attrbases)) - { - HiddKbdBase = OOP_GetMethodID(IID_Hidd_Kbd, 0); - drv = HIDD_Kbd_AddHardwareDriver(kbd, LIBBASE->ksd.kbdclass, NULL); - } - OOP_DisposeObject(kbd); - } - - if (!drv) - return FALSE; - - LIBBASE->library.lib_OpenCnt = 1; - - ReturnInt("AmigaKbd_Init", int, TRUE); -} - -static int AmigaKbd_Expunge(struct kbdbase *LIBBASE) -{ - struct kbd_staticdata *ksd = &LIBBASE->ksd; - struct OOP_ABDescr attrbases[] = - { - {IID_Hidd_Kbd , &LIBBASE->ksd.hiddKbdAB }, - {NULL , NULL } - }; - - EnterFunc(bug("AmigaKbd_Expunge\n")); - - OOP_ReleaseAttrBases(attrbases); - - ReturnInt("AmigaKbd_Expunge", int, TRUE); -} - -ADD2INITLIB(AmigaKbd_Init, 0) -ADD2EXPUNGELIB(AmigaKbd_Expunge, 0) +/* + Copyright © 1995-2006, The AROS Development Team. All rights reserved. + $Id$ + + Desc: kbd Hidd for standalone i386 AROS + Lang: english +*/ + +#include +#include +#include +#include + +#include "kbd.h" + +#include LC_LIBDEFS_FILE + +#undef SDEBUG +#undef DEBUG +#define DEBUG 0 +#include + +static int AmigaKbd_Init(LIBBASETYPEPTR LIBBASE) +{ + struct kbd_staticdata *xsd = &LIBBASE->ksd; + + InitSemaphore( &xsd->sema ); + + return TRUE; +} + +ADD2INITLIB(AmigaKbd_Init, 0) diff --git a/arch/m68k-amiga/hidd/keyboard/mmakefile.src b/arch/m68k-amiga/hidd/keyboard/mmakefile.src index ec58360458..20103fabac 100644 --- a/arch/m68k-amiga/hidd/keyboard/mmakefile.src +++ b/arch/m68k-amiga/hidd/keyboard/mmakefile.src @@ -10,4 +10,4 @@ USER_CPPFLAGS += \ %build_module mmake=kernel-amiga-m68k-kbd \ modname=amigakbd modtype=hidd \ - files="kbd_init kbdclass" uselibs="hiddstubs" + files="startup kbd_init kbdclass" uselibs="hiddstubs" diff --git a/arch/m68k-amiga/hidd/keyboard/kbd_init.c b/arch/m68k-amiga/hidd/keyboard/startup.c similarity index 93% copy from arch/m68k-amiga/hidd/keyboard/kbd_init.c copy to arch/m68k-amiga/hidd/keyboard/startup.c index 0cc7a8b3ce..b8ba0c4bf3 100644 --- a/arch/m68k-amiga/hidd/keyboard/kbd_init.c +++ b/arch/m68k-amiga/hidd/keyboard/startup.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. + Copyright © 1995-2018, The AROS Development Team. All rights reserved. $Id$ */ @@ -31,8 +31,6 @@ static int AmigaKbd_Init(struct kbdbase *LIBBASE) EnterFunc(bug("AmigaKbd_Init\n")); - InitSemaphore( &ksd->sema ); - kbd = OOP_NewObject(NULL, CLID_Hidd_Kbd, NULL); if (kbd) { if (OOP_ObtainAttrBases(attrbases)) diff --git a/arch/m68k-amiga/hidd/mouse/amigamouse.conf b/arch/m68k-amiga/hidd/mouse/amigamouse.conf index 1f97f54943..5525b29f2d 100644 --- a/arch/m68k-amiga/hidd/mouse/amigamouse.conf +++ b/arch/m68k-amiga/hidd/mouse/amigamouse.conf @@ -2,7 +2,7 @@ basename AmigaMouse residentpri 40 libbasetype struct mousebase -version 1.1 +version 1.0 classid CLID_Hidd_Amigamouse superclass CLID_Hidd classptr_field msd.mouseclass diff --git a/arch/m68k-amiga/hidd/mouse/mmakefile.src b/arch/m68k-amiga/hidd/mouse/mmakefile.src index 6a8e9dccf7..72cef7a63d 100644 --- a/arch/m68k-amiga/hidd/mouse/mmakefile.src +++ b/arch/m68k-amiga/hidd/mouse/mmakefile.src @@ -13,4 +13,4 @@ USER_CPPFLAGS += \ %build_module mmake=kernel-amiga-m68k-mouse \ modname=amigamouse modtype=hidd \ - files="mouse_init mouseclass" uselibs=" hiddstubs" + files="startup mouse_init mouseclass" uselibs=" hiddstubs" diff --git a/arch/m68k-amiga/hidd/mouse/mouse_init.c b/arch/m68k-amiga/hidd/mouse/mouse_init.c dissimilarity index 85% index 81c616c61f..5aab25d571 100644 --- a/arch/m68k-amiga/hidd/mouse/mouse_init.c +++ b/arch/m68k-amiga/hidd/mouse/mouse_init.c @@ -1,72 +1,37 @@ -/* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#define DEBUG 0 -#include - -#include -#include - -#include -#include - -#include "mouse.h" - -#undef MSD -#define MSD(cl) msd - -static int AmigaMouse_Init(struct mousebase *LIBBASE) -{ - struct mouse_staticdata *msd = &LIBBASE->msd; - struct OOP_ABDescr attrbases[] = - { - { IID_Hidd, &HiddAttrBase }, - { IID_Hidd_Mouse, &HiddMouseAB }, - { NULL , NULL } - }; - OOP_Object *ms; - OOP_Object *drv = NULL; - - EnterFunc(bug("AmigaMouse_Init\n")); - - InitSemaphore(&msd->sema); - - ms = OOP_NewObject(NULL, CLID_Hidd_Mouse, NULL); - if (ms) { - if (OOP_ObtainAttrBases(attrbases)) - { - HiddMouseBase = OOP_GetMethodID(IID_Hidd_Mouse, 0); - drv = HIDD_Mouse_AddHardwareDriver(ms, LIBBASE->msd.mouseclass, NULL); - } - OOP_DisposeObject(ms); - } - - if (!drv) - return FALSE; - - LIBBASE->library.lib_OpenCnt = 1; - - ReturnInt("AmigaMouse_Init", int, TRUE); -} - -static int AmigaMouse_Expunge(struct mousebase *LIBBASE) -{ - struct mouse_staticdata *msd = &LIBBASE->msd; - struct OOP_ABDescr attrbases[] = - { - { IID_Hidd, &HiddAttrBase }, - { IID_Hidd_Mouse, &HiddMouseAB }, - { NULL , NULL } - }; - - EnterFunc(bug("AmigaMouse_Expunge\n")); - - OOP_ReleaseAttrBases(attrbases); - - ReturnInt("AmigaMouse_Expunge", int, TRUE); -} - -ADD2INITLIB( AmigaMouse_Init, 0) -ADD2EXPUNGELIB(AmigaMouse_Expunge, 0) +/* + Copyright © 1995-2006, The AROS Development Team. All rights reserved. + $Id$ + + Desc: Amiga Mouse hidd + Lang: english +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "mouse.h" + +#include LC_LIBDEFS_FILE + +#undef SDEBUG +#undef DEBUG +#define DEBUG 0 +#include + +static int AmigaMouse_Init(LIBBASETYPEPTR LIBBASE) +{ + struct mouse_staticdata *msd = &LIBBASE->msd; + + D(bug("_mouse: Initializing\n")); + + InitSemaphore(&msd->sema); + + return TRUE; +} + +ADD2INITLIB(AmigaMouse_Init, 0) diff --git a/arch/m68k-amiga/hidd/mouse/mouse_init.c b/arch/m68k-amiga/hidd/mouse/startup.c similarity index 94% copy from arch/m68k-amiga/hidd/mouse/mouse_init.c copy to arch/m68k-amiga/hidd/mouse/startup.c index 81c616c61f..d47b6862a3 100644 --- a/arch/m68k-amiga/hidd/mouse/mouse_init.c +++ b/arch/m68k-amiga/hidd/mouse/startup.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. + Copyright © 1995-2018, The AROS Development Team. All rights reserved. $Id$ */ @@ -31,8 +31,6 @@ static int AmigaMouse_Init(struct mousebase *LIBBASE) EnterFunc(bug("AmigaMouse_Init\n")); - InitSemaphore(&msd->sema); - ms = OOP_NewObject(NULL, CLID_Hidd_Mouse, NULL); if (ms) { if (OOP_ObtainAttrBases(attrbases)) diff --git a/arch/m68k-amiga/hidd/p96gfx/mmakefile.src b/arch/m68k-amiga/hidd/p96gfx/mmakefile.src deleted file mode 100644 index b3d09b9c97..0000000000 --- a/arch/m68k-amiga/hidd/p96gfx/mmakefile.src +++ /dev/null @@ -1,16 +0,0 @@ -# $Id$ - -include $(SRCDIR)/config/aros.cfg - -USER_CPPFLAGS := \ - -D__OOP_NOATTRBASES__ \ - -D__OOP_NOMETHODBASES__ \ - -D__OOP_NOLIBBASE__ \ - -D__GRAPHICS_NOLIBBASE__ \ - -D__UTILITY_NOLIBBASE__ \ - -D__GRAPHICS_NOHIDDBASE__ -USER_LDFLAGS := -static - -%build_module mmake=kernel-amiga-m68k-p96gfx \ - modname=p96gfx modtype=hidd \ - files="p96gfx_startup p96gfx_hiddclass p96gfx_bitmapclass p96gfx_card p96gfx_rtg" diff --git a/arch/m68k-amiga/hidd/p96gfx/p96call.c b/arch/m68k-amiga/hidd/p96gfx/p96call.c deleted file mode 100644 index ba95f38d54..0000000000 --- a/arch/m68k-amiga/hidd/p96gfx/p96call.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. - $Id$ -*/ -/* This program generates the p96call.h macroset for gcc-4.5.1 m68k-elf - * - * WARNING: The header generated by this program is designed - * to work with GCC 4.5.1 m68k-elf ONLY, and even - * then it has only been very lightly tested with - * "-O2 -fomit-frame-pointer -ffixed-a6" - * - * If it breaks, you get to keep both pieces. - */ - -#include - -#define GENCALL_MAX (13 + 1) /* Max number of arguments */ - -static void asm_regs_init(int id, int has_bn, const char *jmp, const char *addr) -{ - int i; - - /* Input values */ - for (i = 0; i < id; i++) - printf("\t ULONG _arg%d = (ULONG)__AROS_LCA(a%d); \\\n", - i + 1, i + 1); - if (has_bn) - printf("\t ULONG _bn_arg = (ULONG)bn; \\\n"); - - /* Define registers */ - printf("\t register volatile ULONG _ret asm(\"%%d0\"); \\\n"); - for (i = 0; i < id; i++) - printf("\t register volatile ULONG __AROS_LTA(a%d) asm(__AROS_LSA(a%d)); \\\n", - i + 1, i + 1); - if (has_bn) - printf("\t register volatile ULONG _bn asm(\"%%a6\"); \\\n"); - - - /* Set registers (non FP) */ - for (i = 1; i <= id; i++) - printf("\t if (! __AROS_ISREG(a%d,__AROS_FP_REG)) { \\\n" - "\t __AROS_LTA(a%d) = _arg%d; } \\\n", - i, i, i); - if (has_bn) - printf("\t if (! __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)) { \\\n" - "\t _bn = _bn_arg; } \\\n"); - - /* Set FP register */ - for (i = 1; i <= id; i++) { - int j; - printf("\t if ( __AROS_ISREG(a%d,__AROS_FP_REG)) { \\\n" - "\t asm volatile (\"move.l %%%%\" __AROS_FP_SREG \",%%%%sp@-\\nmove.l %%0,%%%%\" __AROS_FP_SREG \"\\n%s\\nmove.l %%%%sp@+,%%%%\" __AROS_FP_SREG \"\\n\" : : \"r\" (_arg%d), %s \\\n", - i, jmp, i, addr); - for (j = 0; j < id; j++) - printf("\t\t, \"r\" (__AROS_LTA(a%d)) \\\n", j + 1); - printf("\t ); }\\\n"); - } - if (has_bn) { - int j; - printf("\t if ( __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)) { \\\n" - "\t asm volatile (\"move.l %%%%\" __AROS_FP_SREG \",%%%%sp@-\\nmove.l %%0,%%%%\" __AROS_FP_SREG \"\\n%s\\nmove.l %%%%sp@+,%%%%\" __AROS_FP_SREG \"\\n\" : : \"r\" (_bn_arg), %s \\\n", jmp, addr); - for (j = 0; j < id; j++) - printf("\t\t, \"r\" (__AROS_LTA(a%d)) \\\n", j + 1); - printf("\t ); }\\\n"); - } - if (has_bn || id > 0) { - int j; - printf("\t if (!(0"); - if (has_bn) - printf(" || __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)"); - for (i = 0; i < id; i++) - printf(" || __AROS_ISREG(a%d,__AROS_FP_REG)", i+1); - printf(")) {\\\n" - "\t asm volatile (\"%s\\n\" : : \"i\" (0), %s \\\n", jmp, addr); - for (j = 0; j < id; j++) - printf("\t\t, \"r\" (__AROS_LTA(a%d)) \\\n", j + 1); - printf("\t ); }\\\n"); - } -} - -static void asm_regs_exit(int id, int has_bn) -{ - /* Get the return code */ - printf("\t asm volatile (\"\" : \"=r\" (_ret) : : \"%%a0\", \"%%a1\", \"%%d1\", \"cc\", \"memory\"); \\\n"); - - /* Save retval */ - printf("\t (t)_ret; \\\n"); -} - -static void p96_lc(int id) -{ - int i; - char jmp[256]; - - printf("#define P96_LC%d(t,vector,id", id); - for (i = 0; i < id; i++) - printf(",a%d", i + 1); - printf(") \\\n"); - printf("\t({ APTR _n = (vector);\\\n"); - snprintf(jmp, sizeof(jmp), "move.l %%3,%%%%sp@-\\n" - "pea.l .Lufc%d_%%c2\\n" - "move.l %%1, %%%%sp@-\\n" - "rts\\n" - ".Lufc%d_%%c2:\\n" - "addq.l #4,%%%%sp\\n" - , id, id); - jmp[sizeof(jmp)-1]=0; - asm_regs_init(i, 0, jmp, "\"r\" (_n), \"i\" (__LINE__), \"i\" (id)"); - - asm_regs_exit(i, 0); - printf("\t })\n\n"); -} - -int main(int argc, char **argv) -{ - int i; - - printf("/* AUTOGENERATED by p96call.c */\n"); - printf("/* If you can get this to work for anything other */\n"); - printf("/* than gcc-4.5.1 m68k-elf, it would be surprising. */\n"); - printf("\n"); - printf("#ifndef P96CALL_H\n"); - printf("#define P96CALL_H\n"); - printf("\n"); - printf("/* Call a P96 function */\n"); - printf("\n"); - - for (i = 0; i < GENCALL_MAX; i++) - p96_lc(i); - - printf("#endif /* P96CALL_H */\n"); - return 0; -} diff --git a/arch/m68k-amiga/hidd/p96gfx/p96gfx_bitmap.h b/arch/m68k-amiga/hidd/p96gfx/p96gfx_bitmap.h deleted file mode 100644 index 9df6b3bd31..0000000000 --- a/arch/m68k-amiga/hidd/p96gfx/p96gfx_bitmap.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright 1995-2019, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#ifndef P96GFX_BITMAP_H -#define P96GFX_BITMAP_H - -#define IID_Hidd_BitMap_P96 "hidd.bitmap.p96gfx" - -#include "p96gfx_rtg.h" - -/* This structure is used as instance data for the bitmap class. */ - -struct P96GfxBitMapData -{ - struct MinNode node; - struct SignalSemaphore bmLock; - OOP_Object *pixfmtobj; /* Cached pixelformat object */ - OOP_Object *gfxhidd; /* Cached driver object */ - ULONG rgbformat; - UBYTE *VideoData; - ULONG memsize; - BOOL invram; - WORD width, height, align; - WORD bytesperpixel; - WORD bytesperline; - UBYTE *palette; - WORD topedge, leftedge; - WORD locked; - struct p96gfx_carddata *gfxCardData; -}; - -#define LOCK_BITMAP(data) {ObtainSemaphore(&(data)->bmLock);} -#define TRYLOCK_BITMAP(data) (AttemptSemaphore(&(data)->bmLock)) -#define UNLOCK_BITMAP(data) {ReleaseSemaphore(&(data)->bmLock);} - -#endif /* P96GFX_BITMAP_H */ diff --git a/arch/m68k-amiga/hidd/p96gfx/p96gfx_bitmapclass.c b/arch/m68k-amiga/hidd/p96gfx/p96gfx_bitmapclass.c deleted file mode 100644 index 81061f90fc..0000000000 --- a/arch/m68k-amiga/hidd/p96gfx/p96gfx_bitmapclass.c +++ /dev/null @@ -1,1705 +0,0 @@ -/* - Copyright 1995-2019, The AROS Development Team. All rights reserved. - $Id$ - - Desc: Bitmap class for p96 rtg card drivers. - Lang: English. - -*/ - -/****************************************************************************************/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define DEBUG 0 -#define DB2(x) -#define DEBUG_TEXT(x) -#define DVRAM(x) -#define DCLUT(x) -#include - -#include LC_LIBDEFS_FILE - -#include "p96gfx_intern.h" -#include "p96gfx_bitmap.h" -#include "p96gfx_rtg.h" - -/* LOCK_BITMAP_MULTI: - - swap bitmap between RAM <-> VRAM allowed only if this lock is held - - the bitmap being swapped must also get LOCK_BITMAP lock, otherwise - gfx functions (done by other tasks) could render into wrong place while - bitmap is moved around. - -*/ - -/* poke 0xFF into the videodata for debugging purposes - may be dangerous on some cards! */ -/*#define DEBUG_POKE_VIDEODATA*/ - -static BOOL P96GFXBitmap__ToFRAM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm); - -static APTR P96GFXBitmap__AllocVRAM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - APTR vmem; - - DVRAM(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - SetMemoryMode(cid, RGBFB_CLUT); - vmem = Allocate(cid->vmem, bm->memsize); - SetMemoryMode(cid, bm->rgbformat); - if (vmem) - { - DVRAM(bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p (%dx%dx%d %d): %p,%d bytes VRAM allocated.\n", __func__, bm, bm->width, bm->height, bm->bytesperpixel*8, bm->bytesperline, vmem, bm->memsize)); - } - return vmem; -} - -static BOOL P96GFXBitmap__AllocBM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm, BOOL usevram) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - bm->memsize = (bm->bytesperline * bm->height + 7) & ~7; - - if (!(bm->VideoData = P96GFXBitmap__AllocVRAM(cl, o, bm))) - { - if (usevram && bm->memsize < cid->vram_size) - { - struct P96GfxBitMapData *bmnode; - ForeachNode(&cid->bitmaplist, bmnode) - { - if (bmnode != bm && bmnode->invram && !bmnode->locked) - { - if (P96GFXBitmap__ToFRAM(cl, o, bmnode)) - { - if ((bm->VideoData = P96GFXBitmap__AllocVRAM(cl, o, bm))) - { - cid->vram_used += bm->memsize; - bm->invram = TRUE; - break; - } - } - } - } - } - - if (!bm->VideoData) - { - bm->VideoData = AllocMem(bm->memsize, MEMF_ANY); - if (bm->VideoData) - { - cid->fram_used += bm->memsize; - } - } - } - else - { - cid->vram_used += bm->memsize; - bm->invram = TRUE; - } - DVRAM(bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p (%p:%d) bytes allocated from %s. VRAM=%d\n", __func__, bm, bm->VideoData, bm->memsize, bm->invram ? "VRAM" : "RAM", cid->vram_used)); - -#ifdef DEBUG_POKE_VIDEODATA - /* poke 0xFF into the videodata for debugging purposes - may be dangerous on some cards! */ - if (bm->VideoData != NULL) - { - int i; - - for(i = 0; i < bm->memsize; i++) bm->VideoData[i] = 0xFF; - } -#endif - return bm->VideoData != NULL; -} - -static void P96GFXBitmap__FreeBM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - - DVRAM( - bug("[P96Gfx:Bitmap] %s()\n", __func__); - bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p: freeing %p:%d from %s\n", __func__, bm, bm->VideoData, bm->memsize, bm->invram ? "VRAM" : "RAM"); - ) - - if (bm->invram) - { - SetMemoryMode(cid, RGBFB_CLUT); - Deallocate(cid->vmem, bm->VideoData, bm->memsize); - SetMemoryMode(cid, bm->rgbformat); - cid->vram_used -= bm->memsize; - } - else if (bm->VideoData) - { - FreeMem(bm->VideoData, bm->memsize); - cid->fram_used -= bm->memsize; - } - bm->VideoData = NULL; - bm->invram = FALSE; -} - -static BOOL P96GFXBitmap__ToFRAM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - BOOL ok = FALSE; - APTR vmem; - - DVRAM(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - /* TRYLOCK here as we are in wrong locking order (could deadlock): - - LOCK_BITMAP_MULTI -> LOCK_HW -> [...] <- UNLOCK_HW <- UNLOCK_BITMAP_MULTI - (Correct locking order is: LOCK_BM_MULTI -> LOCK_BM -> LOCK_HW) - - Alternative would be to always lock all (swappable) bitmaps during bitmap - allocation/freeing routines. */ - - if (TRYLOCK_BITMAP(bm)) - { - vmem = AllocMem(bm->memsize, MEMF_ANY); - if (vmem) - { - SetMemoryMode(cid, bm->rgbformat); - CopyMemQuick(bm->VideoData, vmem, bm->memsize); - P96GFXBitmap__FreeBM(cl, o, bm); - bm->VideoData = vmem; - bm->invram = FALSE; - cid->fram_used += bm->memsize; - ok = TRUE; - } - DVRAM(bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p (%p:%d) %d x %d moved to RAM . VRAM=%d\n", __func__, bm->VideoData, bm->memsize, bm, bm->width, bm->height, cid->vram_used)); - - UNLOCK_BITMAP(bm) - } - - return ok; -} - -static BOOL P96GFXBitmap__BMToVRAM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - APTR vmem; - - DVRAM(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - vmem = P96GFXBitmap__AllocVRAM(cl, o, bm); - if (vmem) - { - SetMemoryMode(cid, bm->rgbformat); - CopyMemQuick(bm->VideoData, vmem, bm->memsize); - P96GFXBitmap__FreeBM(cl, o, bm); - bm->VideoData = vmem; - bm->invram = TRUE; - cid->vram_used += bm->memsize; - DVRAM(bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p (%p:%d) %d x %d moved back to VRAM\n", __func__, bm, bm->VideoData, bm->memsize, bm->width, bm->height)); - return TRUE; - } - return FALSE; -} - -static BOOL P96GFXBitmap__ToVRAM(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - struct P96GfxBitMapData *bmnode; - - DVRAM(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - if (bm->invram) - return TRUE; - - DVRAM(bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p (%p:%d) needs to be in VRAM...\n", __func__, bm, bm->VideoData, bm->memsize)); - - ForeachNode(&cid->bitmaplist, bmnode) - { - if (bmnode != bm && bmnode->invram && !bmnode->locked) - { - if (P96GFXBitmap__ToFRAM(cl, o, bmnode)) - { - if (P96GFXBitmap__BMToVRAM(cl, o, bm)) - { - return TRUE; - } - } - } - } - - DVRAM(bug("[P96Gfx:Bitmap] %s: -> not enough memory, VRAM=%d\n", __func__, cid->vram_used)); - - return FALSE; -} - -#if 0 -static BOOL maybeputinvram(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - if (bm->invram) - return TRUE; - if (bm->memsize >= cid->vram_size - cid->vram_used) - return FALSE; - return P96GFXBitmap__BMToVRAM(cl, o, bm); -} -#endif - -static void P96GFXBitmap__HideScreen(OOP_Class *cl, OOP_Object *o, struct P96GfxBitMapData *bm) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx:Bitmap] %s: Bitmap @ 0x%p (%p:%d)\n", - __func__, bm, bm->VideoData, bm->memsize)); - - SetInterrupt(cid, FALSE); - SetDisplay(cid, FALSE); - SetSwitch(cid, FALSE); - cid->dmodeid = 0; - bm->locked--; - cid->disp = NULL; -} - -/****************************************************************************************/ - -#define AO(x) (aoHidd_BitMap_ ## x) -#define GOT_BM_ATTR(code) GOT_ATTR(code, aoHidd_BitMap, bitmap) - -/****************************************************************************************/ - -OOP_Object *P96GFXBitmap__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg) -{ - struct p96gfx_staticdata *csd = CSD(cl); - BOOL ok = TRUE; - struct P96GfxBitMapData *data; - struct p96gfx_carddata *cid; - IPTR width, height, multi; - IPTR displayable; - struct TagItem tags[2]; - ULONG softsflags; - - DB2(bug("[P96Gfx:Bitmap] %s(%x)\n", __func__, o)); - - o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - if (NULL == o) - { - return NULL; - } - - data = OOP_INST_DATA(cl, o); - memset(data, 0, sizeof (*data)); - InitSemaphore(&data->bmLock); - - OOP_GetAttr(o, aHidd_BitMap_Width, &width); - OOP_GetAttr(o, aHidd_BitMap_Height, &height); - OOP_GetAttr(o, aHidd_BitMap_Displayable, &displayable); - OOP_GetAttr(o, aHidd_BitMap_GfxHidd, (APTR)&data->gfxhidd); - OOP_GetAttr(o, aHidd_BitMap_PixFmt, (APTR)&data->pixfmtobj); - OOP_GetAttr(data->pixfmtobj, aHidd_PixFmt_BytesPerPixel, &multi); - - OOP_GetAttr(data->gfxhidd, aHidd_P96Gfx_CardData, (APTR)&data->gfxCardData); - DB2(bug("[P96Gfx:Bitmap] %s: Card Data @ 0x%p\n", __func__, data->gfxCardData)); - cid = data->gfxCardData; - - data->rgbformat = P96GFXRTG__GetFormat(csd, cid, data->pixfmtobj); - - data->align = displayable ? 32 : 16; - width = (width + data->align - 1) & ~(data->align - 1); - data->bytesperline = CalculateBytesPerRow(cid, width, data->rgbformat); - data->width = width; - data->height = height; - data->bytesperpixel = multi; - - LOCK_MULTI_BITMAP - - LOCK_HW /* alloc routines call SetMemoryMode */ - WaitBlitter(cid); /* in case bitmaps are swapped between RAM <-> VRAM during allocation */ - P96GFXBitmap__AllocBM(cl, o, data, TRUE); - UNLOCK_HW - - AddTail(&cid->bitmaplist, (struct Node*)&data->node); - - UNLOCK_MULTI_BITMAP - - tags[0].ti_Tag = aHidd_BitMap_BytesPerRow; - tags[0].ti_Data = data->bytesperline; - tags[1].ti_Tag = TAG_DONE; - OOP_SetAttrs(o, tags); - - DB2(bug("[P96Gfx:Bitmap] %s: %dx%dx%d %d RGBF=%08x P=%08x\n", __func__, width, height, multi, data->bytesperline, data->rgbformat, data->VideoData)); - - if (data->VideoData == NULL) - ok = FALSE; - - if (!ok) { - OOP_MethodID dispose_mid; - dispose_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose); - OOP_CoerceMethod(cl, o, (OOP_Msg)&dispose_mid); - o = NULL; - } - - DB2(bug("[P96Gfx:Bitmap] %s: ret=%x bm=%p (%p:%d)\n", __func__, o, data, data->VideoData, data->memsize)); - - return o; -} - -VOID P96GFXBitmap__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx:Bitmap] %s(%x)\n", __func__, o)); - - LOCK_HW - WaitBlitter(cid); - - DB2(bug("[P96Gfx:Bitmap] %s: bm=%x (%p,%d)\n", __func__, data, data->VideoData, data->memsize)); - if (cid->disp == data) - P96GFXBitmap__HideScreen(cl, o, data); - - UNLOCK_HW - - FreeVec(data->palette); - - LOCK_MULTI_BITMAP - - LOCK_HW /* free functions call SetMemoryMode */ - P96GFXBitmap__FreeBM(cl, o, data); - UNLOCK_HW - - Remove((struct Node*)&data->node); - - UNLOCK_MULTI_BITMAP - - OOP_DoSuperMethod(cl, o, msg); -} - -VOID P96GFXBitmap__Root__Set(OOP_Class *cl, OOP_Object *o, struct pRoot_Set *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - struct TagItem *tag, *tstate; - ULONG idx; - BOOL moved = FALSE; - - DB2(bug("[P96Gfx:Bitmap] %s: %p (%p:%d)\n", __func__, data, data->VideoData, data->memsize)); - tstate = msg->attrList; - while((tag = NextTagItem(&tstate))) - { - DB2(bug("[P96Gfx:Bitmap] %s: Tag %d/%d\n", __func__, tag->ti_Tag, tag->ti_Data)); - if(IS_BITMAP_ATTR(tag->ti_Tag, idx)) - { - DB2(bug("[P96Gfx:Bitmap] %s: BitMap Attr ->%d\n", __func__, idx)); - switch(idx) - { - case aoHidd_BitMap_Focus: - { - ULONG boardType = gl(data->gfxCardData->boardinfo + PSSO_BoardInfo_BoardType); - DB2(bug("[P96Gfx:Bitmap] %s: aoHidd_BitMap_Focus\n", __func__);) - if (boardType == P96BoardType_Vampire) - { - struct GfxBase *GfxBase = (struct GfxBase *)csd->cs_GfxBase; - volatile struct Custom *custom = (struct Custom*)0xdff000; - /* Tell the Vampire SAGA chipset we are visible */ - custom->bplcon0 = GfxBase->system_bplcon0 | 0x80; - } - } - break; - - case aoHidd_BitMap_Visible: - LOCK_MULTI_BITMAP - LOCK_BITMAP(data) - LOCK_HW - if (tag->ti_Data) { - OOP_Object *gfxhidd, *sync, *pf; - IPTR modeid = vHidd_ModeID_Invalid; - IPTR dwidth, dheight, depth, width, height; - struct ModeInfo *modeinfo; - - width = data->width; - height = data->height; - OOP_GetAttr(o, aHidd_BitMap_ModeID , &modeid); - OOP_GetAttr(o, aHidd_BitMap_GfxHidd, (IPTR *)&gfxhidd); - HIDD_Gfx_GetMode(gfxhidd, modeid, &sync, &pf); - OOP_GetAttr(sync, aHidd_Sync_HDisp, &dwidth); - OOP_GetAttr(sync, aHidd_Sync_VDisp, &dheight); - OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth); - data->rgbformat = P96GFXRTG__GetFormat(csd, cid, pf); - modeinfo = P96GFXRTG__GetModeInfo(csd, cid, sync, pf, cid->fakemodeinfo); - cid->modeinfo = modeinfo; - *cid->rgbformat = data->rgbformat; - pw(cid->bitmapextra + PSSO_BitMapExtra_Width, width); - pw(cid->bitmapextra + PSSO_BitMapExtra_Height, height); - D(bug("[P96Gfx:Bitmap] %s: Show %p: (%p:%d) %dx%dx%d (%dx%d) BF=%08x\n", - __func__, data, data->VideoData, data->memsize, - dwidth, dheight, depth, width, height, data->rgbformat)); - - if (!data->invram) - { - WaitBlitter(cid); /* in case other bitmaps are swapped from VRAM to RAM */ - if (!P96GFXBitmap__ToVRAM(cl, o, data)) - { - struct P96GfxBitMapData *bmnode; - - /* Second try. Now lock all bitmaps first. UNLOCK_HW first, to ensure - correct locking order: multibm -> bm -> hw */ - - UNLOCK_HW - - ForeachNode(&cid->bitmaplist, bmnode) - { - if (bmnode != data) LOCK_BITMAP(bmnode) - } - - LOCK_HW - WaitBlitter(cid); /* in case other bitmaps are swapped from VRAM to RAM */ - P96GFXBitmap__ToVRAM(cl, o, data); /* shouldn't fail this time. If it does we are screwed ... */ - UNLOCK_HW - - ForeachNode(&cid->bitmaplist, bmnode) - { - if (bmnode != data) UNLOCK_BITMAP(bmnode) - } - - LOCK_HW - } - } - - cid->dwidth = dwidth; - cid->dheight = dheight; - cid->dmodeid = modeid; - - if (cid->hardwaresprite && depth <= 8) { - HIDDT_Color c; - UWORD i; - UBYTE *clut = data->gfxCardData->boardinfo + PSSO_BoardInfo_CLUT; - for (i = cid->spritepencnt + 1; i < cid->spritepencnt + 4; i++) - { - c.red = clut[i * 3 + 0]; - c.green = clut[i * 3 + 1]; - c.blue = clut[i * 3 + 2]; - HIDD_P96GFX_SetCursorPen(gfxhidd, i, c); - } - } - SetInterrupt(cid, FALSE); - SetColorArray(cid, 0, 256); - SetDisplay(cid, FALSE); - SetGC(cid, modeinfo, 0); - SetClock(cid); - SetDAC(cid); - SetPanning(cid, data->VideoData, width, 0, 0); - SetDisplay(cid, TRUE); - SetSwitch(cid, TRUE); - SetInterrupt(cid, TRUE); - cid->disp = data; - cid->disp->locked++; - } else { - P96GFXBitmap__HideScreen(cl, o, data); - } - UNLOCK_HW - UNLOCK_BITMAP(data) - UNLOCK_MULTI_BITMAP - - break; - case aoHidd_BitMap_LeftEdge: - if (data->leftedge != tag->ti_Data) { - data->leftedge = tag->ti_Data; - moved = TRUE; - } - break; - case aoHidd_BitMap_TopEdge: - if (data->topedge != tag->ti_Data) { - data->topedge = tag->ti_Data; - moved = TRUE; - } - break; - } - } - } - D(bug("[P96Gfx:Bitmap] %s: Exit\n", __func__)); - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); -#if 0 - if (moved && cid->disp == data) - setscroll(cid, data); -#else - (void)moved; -#endif -} - -VOID P96GFXBitmap__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - ULONG idx; - - //DB2(bug("P96GFXBitmap__Root__Get\n")); - if (IS_BITMAP_ATTR(msg->attrID, idx)) { - //DB2(bug("=%d\n", idx)); - switch (idx) { - case aoHidd_BitMap_LeftEdge: - *msg->storage = 0;//data->leftedge; - return; - case aoHidd_BitMap_TopEdge: - *msg->storage = 0;//data->topedge; - return; - case aoHidd_BitMap_Visible: - *msg->storage = cid->disp == data; - return; - case aoHidd_BitMap_Align: - *msg->storage = data->align; - return; - case aoHidd_BitMap_BytesPerRow: - *msg->storage = data->bytesperline; - return; - case aoHidd_BitMap_IsLinearMem: - *msg->storage = TRUE; - return; - } - } - //DB2(bug("P96GFXBitmap__Root__Get Exit\n")); - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); -} - -/****************************************************************************************/ - -static int P96GFXBitmap_Init(LIBBASETYPEPTR LIBBASE) -{ - D(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - return TRUE; //return OOP_ObtainAttrBases(attrbases); -} - -/****************************************************************************************/ - -static int P96GFXBitmap_Expunge(LIBBASETYPEPTR LIBBASE) -{ - D(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - //OOP_ReleaseAttrBases(attrbases); - return TRUE; -} - -/****************************************************************************************/ - -ADD2INITLIB(P96GFXBitmap_Init, 0); -ADD2EXPUNGELIB(P96GFXBitmap_Expunge, 0); - -BOOL P96GFXBitmap__Hidd_BitMap__ObtainDirectAccess(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_ObtainDirectAccess *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - - LOCK_BITMAP(data) - -#if 0 - if (!data->invram) { - if (!P96GFXBitmap__ToVRAM(cl, o, data)) - return FALSE; - } -#endif - - *msg->addressReturn = data->VideoData; - *msg->widthReturn = data->width; - *msg->heightReturn = data->height; - /* undocumented, just a guess.. */ - *msg->bankSizeReturn = *msg->memSizeReturn = data->bytesperline * data->height; - data->locked++; - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - return TRUE; -} - -VOID P96GFXBitmap__Hidd_BitMap__ReleaseDirectAccess(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_ReleaseDirectAccess *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - - data->locked--; - - UNLOCK_BITMAP(data) -} - -BOOL P96GFXBitmap__Hidd_BitMap__SetColors(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_SetColors *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - WORD i, j; - UBYTE *clut; - - DCLUT(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - if (!OOP_DoSuperMethod(cl, o, (OOP_Msg)msg)) - return FALSE; - - LOCK_HW - - WaitBlitter(cid); - clut = data->gfxCardData->boardinfo + PSSO_BoardInfo_CLUT; - DCLUT(bug("[P96Gfx:Bitmap] %s: CLUT @ %p\n", __func__, clut)); - - for (i = msg->firstColor, j = 0; j < msg->numColors; i++, j++) { - clut[i * 3 + 0] = msg->colors[j].red >> 8; - clut[i * 3 + 1] = msg->colors[j].green >> 8; - clut[i * 3 + 2] = msg->colors[j].blue >> 8; - DCLUT(bug("[P96Gfx:Bitmap] %s: color %d %02x%02x%02x\n", __func__, i, msg->colors[j].red >> 8, msg->colors[j].green >> 8, msg->colors[j].blue >> 8)); - } - SetColorArray(cid, msg->firstColor, msg->numColors); - - UNLOCK_HW - - return TRUE; -} - -VOID P96GFXBitmap__Hidd_BitMap__PutPixel(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_PutPixel *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - ULONG offset; - HIDDT_Pixel pixel = msg->pixel; - UBYTE *mem; - - LOCK_BITMAP(data) - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - offset = (msg->x * data->bytesperpixel) + (msg->y * data->bytesperline); - mem = data->VideoData + offset; - - switch(data->bytesperpixel) - { - case 1: - *(UBYTE *)mem = pixel; - break; - - case 2: - *(UWORD *)mem = pixel; - break; - - case 3: - *(UBYTE *)(mem) = pixel >> 16; - *(UBYTE *)(mem + 1) = pixel >> 8; - *(UBYTE *)(mem + 2) = pixel; - break; - - case 4: - *(ULONG *)mem = pixel; - break; - } - - UNLOCK_BITMAP(data) - - return; -} - -/****************************************************************************************/ - -ULONG P96GFXBitmap__Hidd_BitMap__GetPixel(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_GetPixel *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - HIDDT_Pixel pixel = 0; - ULONG offset; - UBYTE *mem; - - LOCK_BITMAP(data) - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - offset = (msg->x * data->bytesperpixel) +(msg->y * data->bytesperline); - mem = data->VideoData + offset; - - switch(data->bytesperpixel) - { - case 1: - pixel = *(UBYTE *)mem; - break; - - case 2: - pixel = *(UWORD *)mem; - break; - - case 3: - pixel = (mem[0] << 16) | (mem[1] << 8) | mem[2]; - break; - - case 4: - pixel = *(ULONG *)mem; - break; - } - - UNLOCK_BITMAP(data) - - return pixel; -} - -/****************************************************************************************/ - -VOID P96GFXBitmap__Hidd_BitMap__DrawLine(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_DrawLine *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - BOOL v = FALSE; - - D(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - LOCK_HW - WaitBlitter(cid); -#if (0) - if (data->invram) { - struct RenderInfo ri; - struct Line renderLine; - P96GFXRTG__MakeRenderInfo(csd, cid, &ri, data); - renderline.FgPen = GC_FG(msg->gc); - renderline.BgPen = GC_BG(msg->gc); - renderline.LinePtrn = GC_LINEPAT(gc); - renderline.X = msg->x1; - renderline.Y = msg->y1; - renderline.dX = msg->x2; - renderline.dY = msg->y2; - v = DrawLine(cid, &ri, &renderLine, data->rgbformat); - } -#endif - UNLOCK_HW - - if (!v) OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); -} - -/****************************************************************************************/ - -VOID P96GFXBitmap__Hidd_BitMap__GetImage(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_GetImage *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - LOCK_BITMAP(data) - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - switch(msg->pixFmt) - { - case vHidd_StdPixFmt_Native: - switch(data->bytesperpixel) - { - case 1: - HIDD_BM_CopyMemBox8(o, - data->VideoData, - msg->x, - msg->y, - msg->pixels, - 0, - 0, - msg->width, - msg->height, - data->bytesperline, - msg->modulo); - break; - - case 2: - HIDD_BM_CopyMemBox16(o, - data->VideoData, - msg->x, - msg->y, - msg->pixels, - 0, - 0, - msg->width, - msg->height, - data->bytesperline, - msg->modulo); - break; - - case 3: - HIDD_BM_CopyMemBox24(o, - data->VideoData, - msg->x, - msg->y, - msg->pixels, - 0, - 0, - msg->width, - msg->height, - data->bytesperline, - msg->modulo); - break; - - case 4: - HIDD_BM_CopyMemBox32(o, - data->VideoData, - msg->x, - msg->y, - msg->pixels, - 0, - 0, - msg->width, - msg->height, - data->bytesperline, - msg->modulo); - break; - } /* switch(data->bytesperpix) */ - break; - - case vHidd_StdPixFmt_Native32: - switch(data->bytesperpixel) - { - case 1: - HIDD_BM_GetMem32Image8(o, - data->VideoData, - msg->x, - msg->y, - msg->pixels, - msg->width, - msg->height, - data->bytesperline, - msg->modulo); - break; - - case 2: - HIDD_BM_GetMem32Image16(o, - data->VideoData, - msg->x, - msg->y, - msg->pixels, - msg->width, - msg->height, - data->bytesperline, - msg->modulo); - break; - - case 3: - HIDD_BM_GetMem32Image24(o, - data->VideoData, - msg->x, - msg->y, - msg->pixels, - msg->width, - msg->height, - data->bytesperline, - msg->modulo); - break; - - case 4: - HIDD_BM_CopyMemBox32(o, - data->VideoData, - msg->x, - msg->y, - msg->pixels, - 0, - 0, - msg->width, - msg->height, - data->bytesperline, - msg->modulo); - break; - } /* switch(data->bytesperpix) */ - break; - - default: - { - APTR pixels = msg->pixels; - APTR srcPixels = data->VideoData + msg->y * data->bytesperline + msg->x * data->bytesperpixel; - OOP_Object *dstpf; - - dstpf = HIDD_Gfx_GetPixFmt(data->gfxhidd, msg->pixFmt); - - HIDD_BM_ConvertPixels(o, &srcPixels, (HIDDT_PixelFormat *)data->pixfmtobj, data->bytesperline, - &pixels, (HIDDT_PixelFormat *)dstpf, msg->modulo, - msg->width, msg->height, NULL); - } - break; - } /* switch(msg->pixFmt) */ - - UNLOCK_BITMAP(data) -} - -/****************************************************************************************/ - -VOID P96GFXBitmap__Hidd_BitMap__PutImage(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_PutImage *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - BOOL v = FALSE; - - D(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - LOCK_BITMAP(data) - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - if (data->invram) - { - if ((msg->pixFmt == vHidd_StdPixFmt_Native - || msg->pixFmt == vHidd_StdPixFmt_Native32 - || msg->pixFmt == vHidd_StdPixFmt_BGRA32 - || msg->pixFmt == vHidd_StdPixFmt_BGR032)) - { -#if (0) - struct RenderInfo ri; - WORD sx, sy, dx, dy; - - P96GFXRTG__MakeRenderInfo(csd, cid, &ri, data); - if (msg->pixels < data->VideoData) - { - } - - LOCK_HW - -// v =BlitRect(cid, &ri, -// WORD sx, WORD sy, WORD dx, WORD dy, msg->width, msg->height, UBYTE mask, data->rgbformat); - - UNLOCK_HW -#endif - } - } - - if (!v) switch(msg->pixFmt) - { - case vHidd_StdPixFmt_Native: - switch(data->bytesperpixel) - { - case 1: - HIDD_BM_CopyMemBox8(o, - msg->pixels, - 0, - 0, - data->VideoData, - msg->x, - msg->y, - msg->width, - msg->height, - msg->modulo, - data->bytesperline); - break; - - case 2: - HIDD_BM_CopyMemBox16(o, - msg->pixels, - 0, - 0, - data->VideoData, - msg->x, - msg->y, - msg->width, - msg->height, - msg->modulo, - data->bytesperline); - break; - - case 3: - HIDD_BM_CopyMemBox24(o, - msg->pixels, - 0, - 0, - data->VideoData, - msg->x, - msg->y, - msg->width, - msg->height, - msg->modulo, - data->bytesperline); - break; - - case 4: - HIDD_BM_CopyMemBox32(o, - msg->pixels, - 0, - 0, - data->VideoData, - msg->x, - msg->y, - msg->width, - msg->height, - msg->modulo, - data->bytesperline); - break; - } /* switch(data->bytesperpix) */ - break; - - case vHidd_StdPixFmt_Native32: - switch(data->bytesperpixel) - { - case 1: - HIDD_BM_PutMem32Image8(o, - msg->pixels, - data->VideoData, - msg->x, - msg->y, - msg->width, - msg->height, - msg->modulo, - data->bytesperline); - break; - - case 2: - HIDD_BM_PutMem32Image16(o, - msg->pixels, - data->VideoData, - msg->x, - msg->y, - msg->width, - msg->height, - msg->modulo, - data->bytesperline); - break; - - case 3: - HIDD_BM_PutMem32Image24(o, - msg->pixels, - data->VideoData, - msg->x, - msg->y, - msg->width, - msg->height, - msg->modulo, - data->bytesperline); - break; - - case 4: - HIDD_BM_CopyMemBox32(o, - msg->pixels, - 0, - 0, - data->VideoData, - msg->x, - msg->y, - msg->width, - msg->height, - msg->modulo, - data->bytesperline); - break; - } /* switch(data->bytesperpix) */ - break; - - default: - { - APTR pixels = msg->pixels; - APTR dstBuf = data->VideoData + msg->y * data->bytesperline + msg->x * data->bytesperpixel; - OOP_Object *srcpf; - - srcpf = HIDD_Gfx_GetPixFmt(data->gfxhidd, msg->pixFmt); - - HIDD_BM_ConvertPixels(o, &pixels, (HIDDT_PixelFormat *)srcpf, msg->modulo, - &dstBuf, (HIDDT_PixelFormat *)data->pixfmtobj, data->bytesperline, - msg->width, msg->height, NULL); - } - break; - } /* switch(msg->pixFmt) */ - - UNLOCK_BITMAP(data) -} - -/****************************************************************************************/ - -VOID P96GFXBitmap__Hidd_BitMap__PutImageLUT(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_PutImageLUT *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - LOCK_BITMAP(data) - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - switch(data->bytesperpixel) - { - case 2: - HIDD_BM_CopyLUTMemBox16(o, - msg->pixels, - 0, - 0, - data->VideoData, - msg->x, - msg->y, - msg->width, - msg->height, - msg->modulo, - data->bytesperline, - msg->pixlut); - break; - - case 3: - HIDD_BM_CopyLUTMemBox24(o, - msg->pixels, - 0, - 0, - data->VideoData, - msg->x, - msg->y, - msg->width, - msg->height, - msg->modulo, - data->bytesperline, - msg->pixlut); - break; - - case 4: - HIDD_BM_CopyLUTMemBox32(o, - msg->pixels, - 0, - 0, - data->VideoData, - msg->x, - msg->y, - msg->width, - msg->height, - msg->modulo, - data->bytesperline, - msg->pixlut); - break; - - default: - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - break; - } /* switch(data->bytesperpix) */ - - UNLOCK_BITMAP(data) -} - -/****************************************************************************************/ - -VOID P96GFXBitmap__Hidd_BitMap__GetImageLUT(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_GetImageLUT *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); -} - -/****************************************************************************************/ - -VOID P96GFXBitmap__Hidd_BitMap__FillRect(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_DrawRect *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - HIDDT_DrawMode mode = GC_DRMD(msg->gc); - HIDDT_Pixel fg = GC_FG(msg->gc); - struct p96gfx_staticdata *csd = CSD(cl); - BOOL v = FALSE; - - D(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - LOCK_BITMAP(data) - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW -#if 0 - maybeputinvram(cid, data); -#endif - - if (data->invram) { - struct RenderInfo ri; - - P96GFXRTG__MakeRenderInfo(csd, cid, &ri, data); - - LOCK_HW - - if (mode == vHidd_GC_DrawMode_Clear || mode == vHidd_GC_DrawMode_Set) { - ULONG pen = mode == vHidd_GC_DrawMode_Clear ? 0x00000000 : 0xffffffff; - v = FillRect(cid, &ri, msg->minX, msg->minY, msg->maxX - msg->minX + 1, msg->maxY - msg->minY + 1, pen, 0xff, data->rgbformat); - } else if (mode == vHidd_GC_DrawMode_Copy) { - v = FillRect(cid, &ri, msg->minX, msg->minY, msg->maxX - msg->minX + 1, msg->maxY - msg->minY + 1, fg, 0xff, data->rgbformat); - } else if (mode == vHidd_GC_DrawMode_Invert) { - v = InvertRect(cid, &ri, msg->minX, msg->minY, msg->maxX - msg->minX + 1, msg->maxY - msg->minY + 1, 0xff, data->rgbformat); - } - - UNLOCK_HW - } - - if (!v) switch(mode) - { - case vHidd_GC_DrawMode_Copy: - switch(data->bytesperpixel) - { - case 1: - HIDD_BM_FillMemRect8(o, - data->VideoData, - msg->minX, - msg->minY, - msg->maxX, - msg->maxY, - data->bytesperline, - fg); - break; - - case 2: - HIDD_BM_FillMemRect16(o, - data->VideoData, - msg->minX, - msg->minY, - msg->maxX, - msg->maxY, - data->bytesperline, - fg); - break; - - case 3: - HIDD_BM_FillMemRect24(o, - data->VideoData, - msg->minX, - msg->minY, - msg->maxX, - msg->maxY, - data->bytesperline, - fg); - break; - - case 4: - HIDD_BM_FillMemRect32(o, - data->VideoData, - msg->minX, - msg->minY, - msg->maxX, - msg->maxY, - data->bytesperline, - fg); - break; - } - break; - - case vHidd_GC_DrawMode_Invert: - HIDD_BM_InvertMemRect(o, - data->VideoData, - msg->minX * data->bytesperpixel, - msg->minY, - msg->maxX * data->bytesperpixel + data->bytesperpixel - 1, - msg->maxY, - data->bytesperline); - break; - - default: - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - break; - } /* switch(mode) */ - - UNLOCK_BITMAP(data) -} - -/****************************************************************************************/ - -VOID P96GFXBitmap__Hidd_BitMap__PutPattern(OOP_Class *cl, OOP_Object *o, - struct pHidd_BitMap_PutPattern *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - HIDDT_Pixel fg = GC_FG(msg->gc); - HIDDT_Pixel bg = GC_BG(msg->gc); - struct Pattern pat; - UBYTE drawmode; - BOOL v = FALSE; - - D(bug("[P96Gfx:Bitmap] %s(%d,%d)(%d,%d)(%x,%d,%d,%d,%d,%d)\n", __func__, - msg->x, msg->y, msg->width, msg->height, - msg->pattern, msg->patternsrcx, msg->patternsrcy, fg, bg, msg->patternheight)); - - LOCK_BITMAP(data) - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - if ((msg->mask == NULL) && (msg->patterndepth == 1)) - { - switch (msg->patternheight) - { - case 1: - pat.Size = 0; - break; - case 2: - pat.Size = 1; - break; - case 4: - pat.Size = 2; - break; - case 8: - pat.Size = 3; - break; - case 16: - pat.Size = 4; - break; - case 32: - pat.Size = 5; - break; - case 64: - pat.Size = 6; - break; - case 128: - pat.Size = 7; - break; - case 256: - pat.Size = 8; - break; - default: - pat.Size = 0xff; - } - - if (pat.Size <= 8) - { -#if 0 - maybeputinvram(cid, data); -#endif - if (data->invram) - { - struct RenderInfo ri; - - P96GFXRTG__MakeRenderInfo(csd, cid, &ri, data); - - if (GC_COLEXP(msg->gc) == vHidd_GC_ColExp_Transparent) - drawmode = JAM1; - else if (GC_DRMD(msg->gc) == vHidd_GC_DrawMode_Invert) - drawmode = COMPLEMENT; - else - drawmode = JAM2; - if (msg->invertpattern) - drawmode |= INVERSVID; - - pat.Memory = msg->pattern; - pat.XOffset = msg->patternsrcx; - pat.YOffset = msg->patternsrcy; - pat.FgPen = fg; - pat.BgPen = bg; - pat.DrawMode = drawmode; - - LOCK_HW - - v = BlitPattern(cid, &ri, &pat, msg->x, msg->y, msg->width, msg->height, 0xff, data->rgbformat); - - UNLOCK_HW - } - } - } - - if (!v) switch(data->bytesperpixel) - { - case 1: - HIDD_BM_PutMemPattern8(o, - msg->gc, - msg->pattern, - msg->patternsrcx, - msg->patternsrcy, - msg->patternheight, - msg->patterndepth, - msg->patternlut, - msg->invertpattern, - msg->mask, - msg->maskmodulo, - msg->masksrcx, - data->VideoData, - data->bytesperline, - msg->x, - msg->y, - msg->width, - msg->height); - break; - - case 2: - HIDD_BM_PutMemPattern16(o, - msg->gc, - msg->pattern, - msg->patternsrcx, - msg->patternsrcy, - msg->patternheight, - msg->patterndepth, - msg->patternlut, - msg->invertpattern, - msg->mask, - msg->maskmodulo, - msg->masksrcx, - data->VideoData, - data->bytesperline, - msg->x, - msg->y, - msg->width, - msg->height); - break; - - case 3: - HIDD_BM_PutMemPattern24(o, - msg->gc, - msg->pattern, - msg->patternsrcx, - msg->patternsrcy, - msg->patternheight, - msg->patterndepth, - msg->patternlut, - msg->invertpattern, - msg->mask, - msg->maskmodulo, - msg->masksrcx, - data->VideoData, - data->bytesperline, - msg->x, - msg->y, - msg->width, - msg->height); - break; - - case 4: - HIDD_BM_PutMemPattern32(o, - msg->gc, - msg->pattern, - msg->patternsrcx, - msg->patternsrcy, - msg->patternheight, - msg->patterndepth, - msg->patternlut, - msg->invertpattern, - msg->mask, - msg->maskmodulo, - msg->masksrcx, - data->VideoData, - data->bytesperline, - msg->x, - msg->y, - msg->width, - msg->height); - break; - - default: - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - break; - } /* switch(data->bytesperpixel) */ - - UNLOCK_BITMAP(data) -} - -/****************************************************************************************/ - -VOID P96GFXBitmap__Hidd_BitMap__PutTemplate(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_PutTemplate *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - HIDDT_Pixel fg = GC_FG(msg->gc); - HIDDT_Pixel bg = GC_BG(msg->gc); - BOOL v = FALSE; - - D(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - LOCK_BITMAP(data) - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - -#if 0 - maybeputinvram(cid, data); -#endif - - if (data->invram) { - struct Template tmpl; - struct RenderInfo ri; - UBYTE drawmode; - - P96GFXRTG__MakeRenderInfo(csd, cid, &ri, data); - - if (GC_COLEXP(msg->gc) == vHidd_GC_ColExp_Transparent) - drawmode = JAM1; - else if (GC_DRMD(msg->gc) == vHidd_GC_DrawMode_Invert) - drawmode = COMPLEMENT; - else - drawmode = JAM2; - if (msg->inverttemplate) - drawmode |= INVERSVID; - - /* tmpl.XOffset has only UBYTE size so we must fix params up [1] [2] */ - - tmpl.Memory = msg->masktemplate + ((msg->srcx / 8) & ~1); /* [1] */ - tmpl.BytesPerRow = msg->modulo; - tmpl.XOffset = msg->srcx & 0XF; /* [2] */ - tmpl.DrawMode = drawmode; - tmpl.FgPen = fg; - tmpl.BgPen = bg; - - LOCK_HW - v = BlitTemplate(cid, &ri, &tmpl, msg->x, msg->y, msg->width, msg->height, 0xff, data->rgbformat); - UNLOCK_HW - } - - if (!v) switch(data->bytesperpixel) - { - case 1: - HIDD_BM_PutMemTemplate8(o, - msg->gc, - msg->masktemplate, - msg->modulo, - msg->srcx, - data->VideoData, - data->bytesperline, - msg->x, - msg->y, - msg->width, - msg->height, - msg->inverttemplate); - break; - - case 2: - HIDD_BM_PutMemTemplate16(o, - msg->gc, - msg->masktemplate, - msg->modulo, - msg->srcx, - data->VideoData, - data->bytesperline, - msg->x, - msg->y, - msg->width, - msg->height, - msg->inverttemplate); - break; - - case 3: - HIDD_BM_PutMemTemplate24(o, - msg->gc, - msg->masktemplate, - msg->modulo, - msg->srcx, - data->VideoData, - data->bytesperline, - msg->x, - msg->y, - msg->width, - msg->height, - msg->inverttemplate); - break; - - case 4: - HIDD_BM_PutMemTemplate32(o, - msg->gc, - msg->masktemplate, - msg->modulo, - msg->srcx, - data->VideoData, - data->bytesperline, - msg->x, - msg->y, - msg->width, - msg->height, - msg->inverttemplate); - break; - - default: - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - break; - } /* switch(data->bytesperpixel) */ - - UNLOCK_BITMAP(data) -} - -/****************************************************************************************/ - -VOID P96GFXBitmap__Hidd_BitMap__UpdateRect(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_UpdateRect *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); -} - -/****************************************************************************************/ - -BOOL P96GFXBitmap__Hidd_PlanarBM__SetBitMap(OOP_Class *cl, OOP_Object *o, - struct pHidd_PlanarBM_SetBitMap *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - return OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); -} - -/****************************************************************************************/ - -BOOL P96GFXBitmap__Hidd_PlanarBM__GetBitMap(OOP_Class *cl, OOP_Object *o, - struct pHidd_PlanarBM_GetBitMap *msg) -{ - struct P96GfxBitMapData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->gfxCardData; - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx:Bitmap] %s()\n", __func__)); - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - return OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); -} diff --git a/arch/m68k-amiga/hidd/p96gfx/p96gfx_card.c b/arch/m68k-amiga/hidd/p96gfx/p96gfx_card.c deleted file mode 100644 index 84262d6c06..0000000000 --- a/arch/m68k-amiga/hidd/p96gfx/p96gfx_card.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - Copyright © 2019, The AROS Development Team. All rights reserved. - $Id$ - - Desc: Stubs used to call into a p96 card driver. -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include "p96gfx_intern.h" -#include "p96gfx_bitmap.h" -#include "p96gfx_rtg.h" -#include "p96call.h" - -static inline APTR __cardFunc(struct p96gfx_carddata *cid, WORD offset) -{ - APTR code = (APTR)((ULONG*)(((UBYTE*)(cid->boardinfo)) + offset))[0]; - D(bug("->RTG off=%d code=%p\n", (offset - (PSSO_BoardInfo_AllocCardMem)) / 4, code)); - pw (cid->boardinfo + PSSO_BoardInfo_AROSFlag, 1); - return code; -} - -BOOL FindCard(struct p96gfx_carddata *cid) -{ - if (cid->CardBase) - return AROS_LVO_CALL1(BOOL, - AROS_LCA(APTR, cid->boardinfo, A0), - struct Library*, cid->CardBase, 5, ); - else - return P96_LC1(BOOL, cid->p96romvector, 16, - AROS_LCA(APTR, cid->boardinfo, A0)); -} - -BOOL InitCard(struct p96gfx_carddata *cid) -{ - if (cid->CardBase) - return AROS_LVO_CALL2(BOOL, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, NULL, A1), - struct Library*, cid->CardBase, 6, ); - else - return P96_LC2(BOOL, cid->p96romvector, 29, - AROS_LCA(APTR, cid->boardinfo, A0), // For current WinP96s - AROS_LCA(APTR, cid->boardinfo, A2)); // For older E-P96s -} - -void WaitBlitter(struct p96gfx_carddata *cid) -{ - if (cid->CardBase) - AROS_CALL1NR(void, __cardFunc(cid, PSSO_BoardInfo_WaitBlitter), - AROS_LCA(APTR, cid->boardinfo, A0), - struct Library*, cid->CardBase); -} - -void SetInterrupt(struct p96gfx_carddata *cid, ULONG state) -{ - if (cid->CardBase) - AROS_CALL2(ULONG, __cardFunc(cid, PSSO_BoardInfo_SetInterrupt), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(ULONG, state, D0), - struct Library*, cid->CardBase); -} - -ULONG GetPixelClock(struct p96gfx_carddata *cid, struct ModeInfo *mi, ULONG index, ULONG rgbformat) -{ - if (cid->CardBase) - return AROS_CALL4(ULONG, __cardFunc(cid, PSSO_BoardInfo_GetPixelClock), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, mi, A1), - AROS_LCA(ULONG, index, D0), - AROS_LCA(ULONG, rgbformat, D7), - struct Library*, cid->CardBase); - else - return -2; -} - -void SetMemoryMode(struct p96gfx_carddata *cid, ULONG rgbformat) -{ - if (cid->CardBase) - AROS_CALL2(ULONG, __cardFunc(cid, PSSO_BoardInfo_SetMemoryMode), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(ULONG, rgbformat, D7), - struct Library*, cid->CardBase); -} - -ULONG ResolvePixelClock(struct p96gfx_carddata *cid, struct ModeInfo *mi, ULONG pixelclock, ULONG rgbformat) -{ - if (cid->CardBase) - return AROS_CALL4(ULONG, __cardFunc(cid, PSSO_BoardInfo_ResolvePixelClock), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, mi, A1), - AROS_LCA(ULONG, pixelclock, D0), - AROS_LCA(ULONG, rgbformat, D7), - struct Library*, cid->CardBase); - else - return -2; -} - -ULONG SetClock(struct p96gfx_carddata *cid) -{ - if (cid->CardBase) - return AROS_CALL1(ULONG, __cardFunc(cid, PSSO_BoardInfo_SetClock), - AROS_LCA(APTR, cid->boardinfo, A0), - struct Library*, cid->CardBase); - else - return -2; -} - -BOOL SetDisplay(struct p96gfx_carddata *cid, BOOL state) -{ - if (cid->CardBase) - return AROS_CALL2(BOOL, __cardFunc(cid, PSSO_BoardInfo_SetDisplay), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(BOOL, state, D0), - struct Library*, cid->CardBase); - else - return P96_LC2(BOOL, cid->p96romvector, 26, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(BOOL, state, D0)); -} - -BOOL SetSwitch(struct p96gfx_carddata *cid, BOOL state) -{ - if (cid->CardBase) - return AROS_CALL2(BOOL, __cardFunc(cid, PSSO_BoardInfo_SetSwitch), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(BOOL, state, D0), - struct Library*, cid->CardBase); - else - return P96_LC2(BOOL, cid->p96romvector, 18, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(BOOL, state, D0)); -} - -void SetColorArray(struct p96gfx_carddata *cid, UWORD start, UWORD count) -{ - if (cid->CardBase) - AROS_CALL3(BOOL, __cardFunc(cid, PSSO_BoardInfo_SetColorArray), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(WORD, start, D0), - AROS_LCA(WORD, count, D1), - struct Library*, cid->CardBase); - else - P96_LC3(BOOL, cid->p96romvector, 19, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(WORD, start, D0), - AROS_LCA(WORD, count, D1)); -} - -void SetDAC(struct p96gfx_carddata *cid) -{ - if (cid->CardBase) - AROS_CALL2(BOOL, __cardFunc(cid, PSSO_BoardInfo_SetDAC), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(ULONG, *cid->rgbformat, D7), - struct Library*, cid->CardBase); - else - P96_LC2(BOOL, cid->p96romvector, 20, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(ULONG, *cid->rgbformat, D7)); -} - -void SetGC(struct p96gfx_carddata *cid, struct ModeInfo *mi, BOOL border) -{ - if (cid->CardBase) - AROS_CALL3(BOOL, __cardFunc(cid, PSSO_BoardInfo_SetGC), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, mi, A1), - AROS_LCA(BOOL, border, D0), - struct Library*, cid->CardBase); - else - P96_LC3(BOOL, cid->p96romvector, 21, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, mi, A1), - AROS_LCA(BOOL, border, D0)); -} - -void SetPanning(struct p96gfx_carddata *cid, UBYTE *video, UWORD width, WORD x, WORD y) -{ - if (cid->CardBase) - AROS_CALL6(BOOL, __cardFunc(cid, PSSO_BoardInfo_SetPanning), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, video, A1), - AROS_LCA(UWORD, width, D0), - AROS_LCA(WORD, x, D1), - AROS_LCA(WORD, y, D2), - AROS_LCA(ULONG, *cid->rgbformat, D7), - struct Library*, cid->CardBase); - else - P96_LC6(BOOL, cid->p96romvector, 22, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, video, A1), - AROS_LCA(UWORD, width, D0), - AROS_LCA(WORD, x, D1), - AROS_LCA(WORD, y, D2), - AROS_LCA(ULONG, *cid->rgbformat, D7)); -} - -BOOL DrawLine(struct p96gfx_carddata *cid, struct RenderInfo *ri, - struct Line * line, ULONG rgbformat) -{ - if (cid->CardBase) { - AROS_CALL4(BOOL, __cardFunc(cid, PSSO_BoardInfo_DrawLine), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, ri, A1), - AROS_LCA(struct Line *, line, A2), - AROS_LCA(ULONG, rgbformat, D7), - struct Library*, cid->CardBase); - return gw (cid->boardinfo + PSSO_BoardInfo_AROSFlag); - } -#if (0) - else - return P96_LC4(BOOL, cid->p96romvector, 28, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, ri, A1), - AROS_LCA(struct Line *, line, A2), - AROS_LCA(ULONG, rgbformat, D7)); -#else - return FALSE; -#endif -} - -BOOL BlitRect(struct p96gfx_carddata *cid, struct RenderInfo *ri, - WORD sx, WORD sy, WORD dx, WORD dy, WORD w, WORD h, UBYTE mask, ULONG rgbformat) -{ - if (cid->CardBase) { - AROS_CALL10(BOOL, __cardFunc(cid, PSSO_BoardInfo_BlitRect), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, ri, A1), - AROS_LCA(WORD, sx, D0), - AROS_LCA(WORD, sy, D1), - AROS_LCA(WORD, dx, D2), - AROS_LCA(WORD, dy, D3), - AROS_LCA(WORD, w, D4), - AROS_LCA(WORD, h, D5), - AROS_LCA(UBYTE, mask, D6), - AROS_LCA(ULONG, rgbformat, D7), - struct Library*, cid->CardBase); - return gw (cid->boardinfo + PSSO_BoardInfo_AROSFlag); - } -#if (0) - else - return P96_LC10(BOOL, cid->p96romvector, 28, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, ri, A1), - AROS_LCA(WORD, sx, D0), - AROS_LCA(WORD, sy, D1), - AROS_LCA(WORD, dx, D2), - AROS_LCA(WORD, dy, D3), - AROS_LCA(WORD, w, D4), - AROS_LCA(WORD, h, D5), - AROS_LCA(UBYTE, mask, D6), - AROS_LCA(ULONG, rgbformat, D7)); -#else - return FALSE; -#endif -} - -BOOL FillRect(struct p96gfx_carddata *cid, struct RenderInfo *ri, WORD x, WORD y, WORD w, WORD h, ULONG pen, UBYTE mask, ULONG rgbformat) -{ - if (cid->CardBase) { - AROS_CALL9(BOOL, __cardFunc(cid, PSSO_BoardInfo_FillRect), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, ri, A1), - AROS_LCA(WORD, x, D0), - AROS_LCA(WORD, y, D1), - AROS_LCA(WORD, w, D2), - AROS_LCA(WORD, h, D3), - AROS_LCA(ULONG, pen, D4), - AROS_LCA(UBYTE, mask, D5), - AROS_LCA(ULONG, rgbformat, D7), - struct Library*, cid->CardBase); - return gw (cid->boardinfo + PSSO_BoardInfo_AROSFlag); - } else - return P96_LC9(BOOL, cid->p96romvector, 17, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, ri, A1), - AROS_LCA(WORD, x, D0), - AROS_LCA(WORD, y, D1), - AROS_LCA(WORD, w, D2), - AROS_LCA(WORD, h, D3), - AROS_LCA(ULONG, pen, D4), - AROS_LCA(UBYTE, mask, D5), - AROS_LCA(ULONG, rgbformat, D7)); -} - -BOOL InvertRect(struct p96gfx_carddata *cid, struct RenderInfo *ri, WORD x, WORD y, WORD w, WORD h, UBYTE mask, ULONG rgbformat) -{ - if (cid->CardBase) { - AROS_CALL8(BOOL, __cardFunc(cid, PSSO_BoardInfo_InvertRect), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, ri, A1), - AROS_LCA(WORD, x, D0), - AROS_LCA(WORD, y, D1), - AROS_LCA(WORD, w, D2), - AROS_LCA(WORD, h, D3), - AROS_LCA(UBYTE, mask, D4), - AROS_LCA(ULONG, rgbformat, D7), - struct Library*, cid->CardBase); - return gw (cid->boardinfo + PSSO_BoardInfo_AROSFlag); - } else - return P96_LC8(BOOL, cid->p96romvector, 31, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, ri, A1), - AROS_LCA(WORD, x, D0), - AROS_LCA(WORD, y, D1), - AROS_LCA(WORD, w, D2), - AROS_LCA(WORD, h, D3), - AROS_LCA(UBYTE, mask, D4), - AROS_LCA(ULONG, rgbformat, D7)); -} - -BOOL BlitRectNoMaskComplete(struct p96gfx_carddata *cid, struct RenderInfo *risrc, struct RenderInfo *ridst, - WORD sx, WORD sy, WORD dx, WORD dy, WORD w, WORD h, UBYTE opcode, ULONG rgbformat) -{ - if (cid->CardBase) { - AROS_CALL11(BOOL, __cardFunc(cid, PSSO_BoardInfo_BlitRectNoMaskComplete), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, risrc, A1), - AROS_LCA(APTR, ridst, A2), - AROS_LCA(WORD, sx, D0), - AROS_LCA(WORD, sy, D1), - AROS_LCA(WORD, dx, D2), - AROS_LCA(WORD, dy, D3), - AROS_LCA(WORD, w, D4), - AROS_LCA(WORD, h, D5), - AROS_LCA(UBYTE, opcode, D6), - AROS_LCA(ULONG, rgbformat, D7), - struct Library*, cid->CardBase); - return gw (cid->boardinfo + PSSO_BoardInfo_AROSFlag); - } else - return P96_LC11(BOOL, cid->p96romvector, 28, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, risrc, A1), - AROS_LCA(APTR, ridst, A2), - AROS_LCA(WORD, sx, D0), - AROS_LCA(WORD, sy, D1), - AROS_LCA(WORD, dx, D2), - AROS_LCA(WORD, dy, D3), - AROS_LCA(WORD, w, D4), - AROS_LCA(WORD, h, D5), - AROS_LCA(UBYTE, opcode, D6), - AROS_LCA(ULONG, rgbformat, D7)); -} - -BOOL BlitPattern(struct p96gfx_carddata *cid, struct RenderInfo *ri, struct Pattern *pat, - WORD x, WORD y, WORD w, WORD h, UBYTE mask, ULONG rgbformat) -{ - if (cid->CardBase) { - AROS_CALL9(BOOL, __cardFunc(cid, PSSO_BoardInfo_BlitPattern), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, ri, A1), - AROS_LCA(APTR, pat, A2), - AROS_LCA(WORD, x, D0), - AROS_LCA(WORD, y, D1), - AROS_LCA(WORD, w, D2), - AROS_LCA(WORD, h, D3), - AROS_LCA(UBYTE, mask, D4), - AROS_LCA(ULONG, rgbformat, D7), - struct Library*, cid->CardBase); - return gw (cid->boardinfo + PSSO_BoardInfo_AROSFlag); - } else - return P96_LC9(BOOL, cid->p96romvector, 30, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, ri, A1), - AROS_LCA(APTR, pat, A2), - AROS_LCA(WORD, x, D0), - AROS_LCA(WORD, y, D1), - AROS_LCA(WORD, w, D2), - AROS_LCA(WORD, h, D3), - AROS_LCA(UBYTE, mask, D4), - AROS_LCA(ULONG, rgbformat, D7)); -} - -BOOL BlitTemplate(struct p96gfx_carddata *cid, struct RenderInfo *ri, struct Template *tmpl, - WORD x, WORD y, WORD w, WORD h, UBYTE mask, ULONG rgbformat) -{ - if (cid->CardBase) { - AROS_CALL9(BOOL, __cardFunc(cid, PSSO_BoardInfo_BlitTemplate), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, ri, A1), - AROS_LCA(APTR, tmpl, A2), - AROS_LCA(WORD, x, D0), - AROS_LCA(WORD, y, D1), - AROS_LCA(WORD, w, D2), - AROS_LCA(WORD, h, D3), - AROS_LCA(UBYTE, mask, D4), - AROS_LCA(ULONG, rgbformat, D7), - struct Library*, cid->CardBase); - return gw (cid->boardinfo + PSSO_BoardInfo_AROSFlag); - } else - return P96_LC9(BOOL, cid->p96romvector, 27, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(APTR, ri, A1), - AROS_LCA(APTR, tmpl, A2), - AROS_LCA(WORD, x, D0), - AROS_LCA(WORD, y, D1), - AROS_LCA(WORD, w, D2), - AROS_LCA(WORD, h, D3), - AROS_LCA(UBYTE, mask, D4), - AROS_LCA(ULONG, rgbformat, D7)); -} - -WORD CalculateBytesPerRow(struct p96gfx_carddata *cid, WORD width, ULONG rgbformat) -{ - if (cid->CardBase) - return AROS_CALL3(BOOL, __cardFunc(cid, PSSO_BoardInfo_CalculateBytesPerRow), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(UWORD, width, D0), - AROS_LCA(ULONG, rgbformat, D7), - struct Library*, cid->CardBase); - else - return P96_LC3(BOOL, cid->p96romvector, 23, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(UWORD, width, D0), - AROS_LCA(ULONG, rgbformat, D7)); -} - -BOOL SetSprite(struct p96gfx_carddata *cid, BOOL activate) -{ - if (cid->CardBase) - return AROS_CALL3(BOOL, __cardFunc(cid, PSSO_BoardInfo_SetSprite), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(BOOL, activate, D0), - AROS_LCA(ULONG, *cid->rgbformat, D7), - struct Library*, cid->CardBase); - return P96_LC3(BOOL, cid->p96romvector, 36, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(BOOL, activate, D0), - AROS_LCA(ULONG, *cid->rgbformat, D7)); -} - -BOOL SetSpritePosition(struct p96gfx_carddata *cid) -{ - if (cid->CardBase) - return AROS_CALL2(BOOL, __cardFunc(cid, PSSO_BoardInfo_SetSpritePosition), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(ULONG, *cid->rgbformat, D7), - struct Library*, cid->CardBase); - return P96_LC2(BOOL, cid->p96romvector, 37, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(ULONG, *cid->rgbformat, D7)); -} - -BOOL SetSpriteImage(struct p96gfx_carddata *cid) -{ - if (cid->CardBase) - return AROS_CALL2(BOOL, __cardFunc(cid, PSSO_BoardInfo_SetSpriteImage), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(ULONG, *cid->rgbformat, D7), - struct Library*, cid->CardBase); - return P96_LC2(BOOL, cid->p96romvector, 38, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(ULONG, *cid->rgbformat, D7)); -} - -BOOL SetSpriteColor(struct p96gfx_carddata *cid, UBYTE idx, UBYTE r, UBYTE g, UBYTE b) -{ - if (cid->CardBase) - return AROS_CALL6(BOOL, __cardFunc(cid, PSSO_BoardInfo_SetSpriteColor), - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(UBYTE, idx, D0), - AROS_LCA(UBYTE, r, D1), - AROS_LCA(UBYTE, g, D2), - AROS_LCA(UBYTE, b, D3), - AROS_LCA(ULONG, *cid->rgbformat, D7), - struct Library*, cid->CardBase); - return P96_LC6(BOOL, cid->p96romvector, 39, - AROS_LCA(APTR, cid->boardinfo, A0), - AROS_LCA(UBYTE, idx, D0), - AROS_LCA(UBYTE, r, D1), - AROS_LCA(UBYTE, g, D2), - AROS_LCA(UBYTE, b, D3), - AROS_LCA(ULONG, *cid->rgbformat, D7)); -} diff --git a/arch/m68k-amiga/hidd/p96gfx/p96gfx_hidd.h b/arch/m68k-amiga/hidd/p96gfx/p96gfx_hidd.h deleted file mode 100644 index 093cf4a9ad..0000000000 --- a/arch/m68k-amiga/hidd/p96gfx/p96gfx_hidd.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef P96GFX_HIDD_H -#define P96GFX_HIDD_H - -#include -#include - -#include - -#include "p96gfx_intern.h" - -#define P96GFX_LIBNAME "p96gfx.hidd" -#define CLID_Hidd_Gfx_P96 IID_Hidd_P96Gfx - -/* Private instance data for P96Gfx hidd class */ -struct P96GfxData -{ - struct MinList bitmaps; /* Currently shown bitmap objects */ - OOP_Object *spriteColors; - OOP_Object *pfo; - struct p96gfx_carddata *cardData; -}; - -#endif /* P96GFX_HIDD_H */ diff --git a/arch/m68k-amiga/hidd/p96gfx/p96gfx_hiddclass.c b/arch/m68k-amiga/hidd/p96gfx/p96gfx_hiddclass.c deleted file mode 100644 index 9cb62934cb..0000000000 --- a/arch/m68k-amiga/hidd/p96gfx/p96gfx_hiddclass.c +++ /dev/null @@ -1,1657 +0,0 @@ -/* - Copyright 1995-2019, The AROS Development Team. All rights reserved. - $Id$ - - Desc: P96 rtg card Gfx Hidd wrapper. - Lang: English. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#include LC_LIBDEFS_FILE - -#include "p96gfx_intern.h" -#include "p96gfx_bitmap.h" -#include "p96gfx_rtg.h" - -#define SDEBUG 0 -#define DEBUG 0 -#define DRTG(x) -#define DEXTRA(x) -#include - -#define SIZE_RESLIST 5 -#define SIZE_PFLIST 19 -#define SIZE_MODELIST (5 + RGBFB_MaxFormats) - -#define SPRITE_PEN_COUNT 16 -/* REMOVE-ME: 4MB Hack (used for easier debug of vram <-> ram swapping) !!!!*/ -/*#define USE_VRAM_HACK*/ - -HIDDT_ModeID *P96GFXCl__Hidd_Gfx__QueryModeIDs(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_QueryModeIDs *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - struct RTGMode *node; - struct TagItem *tag, *tstate; - ULONG minwidth = 0, maxwidth = 0xFFFFFFFF; - ULONG minheight = 0, maxheight = 0xFFFFFFFF; - OOP_Object **pf = NULL; - HIDDT_ModeID *modeids; - WORD cnt; - - if (cid->superforward) - return (HIDDT_ModeID*)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - - for (tstate = msg->queryTags; (tag = NextTagItem(&tstate)); ) - { - switch (tag->ti_Tag) - { - case tHidd_GfxMode_MinWidth: - minwidth = (ULONG)tag->ti_Tag; - break; - - case tHidd_GfxMode_MaxWidth: - maxwidth = (ULONG)tag->ti_Tag; - break; - - case tHidd_GfxMode_MinHeight: - minheight = (ULONG)tag->ti_Tag; - break; - - case tHidd_GfxMode_MaxHeight: - maxheight = (ULONG)tag->ti_Tag; - break; - - case tHidd_GfxMode_PixFmts: - pf = (OOP_Object**)tag->ti_Tag; - break; - } - } - DB2(bug("[P96Gfx] %s: (%dx%d)-(%dx%d) %p\n", __func__, minwidth, minheight, maxwidth, maxheight, pf);) - cnt = 0; - ForeachNode(&cid->rtglist, node) { - if (node->width >= minwidth && node->width <= maxwidth && node->height >= minheight && node->height <= maxheight) { - OOP_Object **pfp = NULL; - if (pf) { - pfp = pf; - while (*pfp) { - if (*pfp == node->pf) { - pfp = NULL; - break; - } - pfp++; - } - } - if (!pfp) - cnt++; - } - } - modeids = AllocVec((cnt + 1) * sizeof(HIDDT_ModeID), MEMF_PUBLIC); - if (!modeids) - return NULL; - cnt = 0; - ForeachNode(&cid->rtglist, node) { - if (node->width >= minwidth && node->width <= maxwidth && node->height >= minheight && node->height <= maxheight) { - OOP_Object **pfp = NULL; - if (pf) { - pfp = pf; - while (*pfp) { - if (*pfp == node->pf) { - pfp = NULL; - break; - } - pfp++; - } - } - if (!pfp) { - DB2(bug("[P96Gfx] %s: #%d %08x\n", __func__, cnt, node->modeid);) - modeids[cnt++] = node->modeid; - } - } - } - modeids[cnt] = vHidd_ModeID_Invalid; - return modeids; -} - -VOID P96GFXCl__Hidd_Gfx__ReleaseModeIDs(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_ReleaseModeIDs *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - - if (cid->superforward) - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - else - FreeVec(msg->modeIDs); -} - -HIDDT_ModeID P96GFXCl__Hidd_Gfx__NextModeID(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_NextModeID *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - struct RTGMode *node = NULL; - HIDDT_ModeID mid = vHidd_ModeID_Invalid; - - DB2(bug("[P96Gfx] %s(%08x)\n", __func__, msg->modeID);) - - if (msg->modeID != vHidd_ModeID_Invalid) { - ForeachNode(&cid->rtglist, node) { - if (node->modeid == msg->modeID) { - node = (struct RTGMode*)node->node.ln_Succ; - break; - } - } - } - if (!node) - node = (struct RTGMode*)cid->rtglist.lh_Head; - if (node->node.ln_Succ) { - mid = node->modeid; - *msg->syncPtr = node->sync; - *msg->pixFmtPtr = node->pf; - } - DB2(bug("[P96Gfx] %s: %08x %p %p\n", __func__, mid, *msg->syncPtr, *msg->pixFmtPtr);) - return mid; -} - -BOOL P96GFXCl__Hidd_Gfx__GetMode(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_GetMode *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - struct RTGMode *node; - - DB2(bug("[P96Gfx] %s(%08x)\n", __func__, msg->modeID);) - - if (cid->superforward) - return (BOOL)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - - ForeachNode(&cid->rtglist, node) { - if (node->modeid == msg->modeID) { - *msg->syncPtr = node->sync; - *msg->pixFmtPtr = node->pf; - DB2(bug("[P96Gfx] %s: %p %p\n", __func__, node->sync, node->pf);) - return TRUE; - } - } - DB2(bug("[P96Gfx] %s: FAIL\n", __func__);) - return FALSE; -} - -struct RTGFormat -{ - UWORD rgbformat; - ULONG rm, gm, bm, am; - UWORD rs, gs, bs, as; - BOOL endianswap; -}; - -static const struct RTGFormat formats[] = -{ - { RGBFB_CLUT, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000, 8, 16, 24, 0, FALSE }, - - { RGBFB_B8G8R8A8, 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff, 16, 8, 0, 24, FALSE }, - { RGBFB_R8G8B8A8, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff, 0, 8, 16, 24, FALSE }, - { RGBFB_A8B8G8R8, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, 24, 16, 8, 0, FALSE }, - { RGBFB_A8R8G8B8, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000, 8, 16, 24, 0, FALSE }, - - { RGBFB_B8G8R8, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000, 24, 16, 8, 0, FALSE }, - { RGBFB_R8G8B8, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000, 8, 16, 24, 0, FALSE }, - - { RGBFB_R5G5B5, 0x00007c00, 0x000003e0, 0x0000001f, 0x00000000, 17, 22, 27, 0, FALSE }, - { RGBFB_R5G6B5, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000, 16, 21, 27, 0, FALSE }, - - { RGBFB_R5G5B5PC, 0x00007c00, 0x000003e0, 0x0000001f, 0x00000000, 17, 22, 27, 0, TRUE }, - { RGBFB_R5G6B5PC, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000, 16, 21, 27, 0, TRUE }, -/* - { RGBFB_B5G5R5PC, 0x0000003e, 0x000007c0, 0x0000f800, 0x00000000, 26, 21, 16, 0, TRUE }, - { RGBFB_B5G6R5PC, 0x0000001f, 0x000007e0, 0x0000f800, 0x00000000, 27, 21, 16, 0, TRUE }, -*/ - { 0 } -}; - -static const UBYTE rgbtypelist[] = { - RGBFB_CLUT, - - RGBFB_R5G6B5PC, - RGBFB_R5G5B5PC, - RGBFB_B5G6R5PC, - RGBFB_B5G5R5PC, - RGBFB_R5G6B5, - RGBFB_R5G5B5, - - RGBFB_B8G8R8, - RGBFB_R8G8B8, - - RGBFB_B8G8R8A8, - RGBFB_A8B8G8R8, - RGBFB_A8R8G8B8, - RGBFB_R8G8B8A8, - 0 -}; - -char *P96GFX__MakeBoardName(struct p96gfx_carddata *cid) -{ - char *BoardName = gp(cid->boardinfo + PSSO_BoardInfo_BoardName); - if (BoardName) - return BoardName; - ULONG boardType = gl(cid->boardinfo + PSSO_BoardInfo_BoardType); - switch (boardType) - { - case P96BoardType_UAEGfx: - return "UAE"; - case P96BoardType_Vampire: - return "SAGA"; - case P96BoardType_Pixel64: - return "Pixel64"; - case P96BoardType_PicassoIV: - return "PicassoIV"; - case P96BoardType_PiccoloSD64: - return "PiccoloSD64"; - case P96BoardType_PicassoII: - return "PicassoII"; - case P96BoardType_Piccolo: - return "Piccolo"; - case P96BoardType_RetinaBLT: - return "RetinaBLT"; - case P96BoardType_A2410: - return "A2410"; - } - return NULL; -} - -OOP_Object *P96GFXCl__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg) -{ - struct p96gfx_staticdata *csd = CSD(cl); - struct LibResolution *r; - struct TagItem *reslist, *restags, *pflist, *modetags; - struct TagItem mytags[] = { - { aHidd_Gfx_ModeTags, 0 }, - { aHidd_Name, (IPTR)"p96gfx.hidd" }, - { aHidd_HardwareName, 0 }, - { aHidd_ProducerName, (IPTR)"P96" }, - { TAG_MORE, 0UL } - }; - struct pRoot_New mymsg; - char *BoardName; - UWORD supportedformats, gotmodes; - WORD rescnt, i, j, k, l; - struct p96gfx_carddata *cid = (struct p96gfx_carddata *)GetTagData(aHidd_P96Gfx_CardData, NULL, msg->attrList); - - if (!cid || cid->initialized) - return NULL; - - NEWLIST(&cid->rtglist); - NEWLIST(&cid->bitmaplist); - InitSemaphore(&cid->HWLock); - InitSemaphore(&cid->MultiBMLock); - - BoardName = P96GFX__MakeBoardName(cid); - if (BoardName) - { - D(bug("[P96Gfx] %s: BoardName '%s'\n", __func__, BoardName);) - cid->p96gfx_HWName = AllocVec(strlen(BoardName) + 18, MEMF_PUBLIC); - cid->p96gfx_HWResTmplt = AllocVec(strlen(BoardName) + 7, MEMF_PUBLIC); - sprintf(cid->p96gfx_HWName, "%s P96 Card Wrapper", BoardName); - sprintf(cid->p96gfx_HWResTmplt, "%s:%%hx%%v", BoardName); - } - else - { - cid->p96gfx_HWResTmplt = (cid->CardBase) ? "RTGFX:%hx%v" : "P96:%hx%v"; - cid->p96gfx_HWName = "P96 Card Wrapper"; - } - mytags[2].ti_Data = (IPTR)cid->p96gfx_HWName; - - supportedformats = gw(cid->boardinfo + PSSO_BoardInfo_RGBFormats); - - rescnt = 0; - ForeachNode(cid->boardinfo + PSSO_BoardInfo_ResolutionsList, r) { - rescnt++; - } - D(bug("[P96Gfx] %s: resolutions: %d, supportmask: %x\n", __func__, rescnt, supportedformats);) - - reslist = AllocVec(rescnt * SIZE_RESLIST * sizeof(struct TagItem), MEMF_PUBLIC | MEMF_CLEAR); - restags = AllocVec((rescnt + 1) * sizeof(struct TagItem), MEMF_PUBLIC | MEMF_CLEAR); - pflist = AllocVec(RGBFB_MaxFormats * SIZE_PFLIST * sizeof(struct TagItem), MEMF_PUBLIC | MEMF_CLEAR); - modetags = AllocVec(SIZE_MODELIST * sizeof(struct TagItem), MEMF_PUBLIC | MEMF_CLEAR); - - i = 0; - ForeachNode(cid->boardinfo + PSSO_BoardInfo_ResolutionsList, r) { - reslist[i * SIZE_RESLIST + 0].ti_Tag = aHidd_Sync_HDisp; - reslist[i * SIZE_RESLIST + 0].ti_Data = r->Width; - reslist[i * SIZE_RESLIST + 1].ti_Tag = aHidd_Sync_VDisp; - reslist[i * SIZE_RESLIST + 1].ti_Data = r->Height; - reslist[i * SIZE_RESLIST + 2].ti_Tag = aHidd_Sync_Description; - reslist[i * SIZE_RESLIST + 2].ti_Data = (IPTR)cid->p96gfx_HWResTmplt; - reslist[i * SIZE_RESLIST + 3].ti_Tag = aHidd_Sync_PixelClock; - reslist[i * SIZE_RESLIST + 3].ti_Data = r->Modes[CHUNKY]->PixelClock; - reslist[i * SIZE_RESLIST + 4].ti_Tag = TAG_DONE; - reslist[i * SIZE_RESLIST + 4].ti_Data = 0; - D(bug("[P96Gfx] %s: %08x %d*%d\n", __func__, r, r->Width, r->Height);) - restags[i].ti_Tag = aHidd_Gfx_SyncTags; - restags[i].ti_Data = (IPTR)&reslist[i * SIZE_RESLIST]; - i++; - } - restags[i].ti_Tag = TAG_DONE; - restags[i].ti_Data = 0; - - gotmodes = 0; - k = 0; - j = 0; - for (i = 0; rgbtypelist[i]; i++) { - UBYTE rgbtype = rgbtypelist[i]; - WORD depth = P96GFXRTG__GetDepth(1 << rgbtype); - if (!((1 << rgbtype) & RGBFB_SUPPORTMASK) || depth == 0 || !((1 << rgbtype) & supportedformats)) { - pflist[j].ti_Tag = TAG_DONE; - pflist[j].ti_Data = 0; - j++; - continue; - } - for (l = 0; formats[l].rgbformat; l++) { - if (formats[l].rgbformat == rgbtype) - break; - } - if (formats[l].rgbformat == 0) { - pflist[j].ti_Tag = TAG_DONE; - pflist[j].ti_Data = 0; - j++; - continue; - } - D(bug("[P96Gfx] %s: RTGFORMAT=%d found. Depth=%d\n", __func__, rgbtype, depth);) - - if (gotmodes & (1 << (depth / 8))) { - D(bug("[P96Gfx] %s: -> skipped\n", __func__);) - pflist[j].ti_Tag = TAG_DONE; - pflist[j].ti_Data = 0; - j++; - continue; - } - - gotmodes |= 1 << (depth / 8); - - modetags[k].ti_Tag = aHidd_Gfx_PixFmtTags; - modetags[k].ti_Data = (IPTR)&pflist[j]; - k++; - - pflist[j].ti_Tag = aHidd_PixFmt_RedShift; - pflist[j].ti_Data = formats[l].rs; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_GreenShift; - pflist[j].ti_Data = formats[l].gs; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_BlueShift; - pflist[j].ti_Data = formats[l].bs; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_AlphaShift; - pflist[j].ti_Data = formats[l].as; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_RedMask; - pflist[j].ti_Data = formats[l].rm; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_GreenMask; - pflist[j].ti_Data = formats[l].gm; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_BlueMask; - pflist[j].ti_Data = formats[l].bm; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_AlphaMask; - pflist[j].ti_Data = formats[l].am; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_CLUTMask; - pflist[j].ti_Data = 0x000000FF; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_CLUTShift; - pflist[j].ti_Data = 0; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_ColorModel; - pflist[j].ti_Data = depth <= 8 ? vHidd_ColorModel_Palette : vHidd_ColorModel_TrueColor; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_Depth; - pflist[j].ti_Data = depth; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_BytesPerPixel; - pflist[j].ti_Data = (depth + 7) / 8; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_BitsPerPixel; - pflist[j].ti_Data = depth; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_StdPixFmt; - pflist[j].ti_Data = vHidd_StdPixFmt_Native; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_BitMapType; - pflist[j].ti_Data = vHidd_BitMapType_Chunky; - j++; - pflist[j].ti_Tag = aHidd_PixFmt_SwapPixelBytes; - pflist[j].ti_Data = formats[l].endianswap; - j++; - pflist[j].ti_Tag = TAG_DONE; - pflist[j].ti_Data = 0; - j++; - } - - modetags[k].ti_Tag = aHidd_Sync_HMin; - modetags[k].ti_Data = 112; - k++; - modetags[k].ti_Tag = aHidd_Sync_VMin; - modetags[k].ti_Data = 112; - k++; - modetags[k].ti_Tag = aHidd_Sync_HMax; - modetags[k].ti_Data = 16384; - k++; - modetags[k].ti_Tag = aHidd_Sync_VMax; - modetags[k].ti_Data = 16384; - k++; - modetags[k].ti_Tag = TAG_MORE; - modetags[k].ti_Data = (IPTR)restags; - - mytags[0].ti_Data = (IPTR)modetags; - - EnterFunc(bug("[P96Gfx] %s: tags @ %x\n", __func__, mytags);) - - mymsg.mID = msg->mID; - mymsg.attrList = mytags; - msg = &mymsg; - - /* Register gfxmodes */ - o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - if (NULL != o) - { - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct TagItem cmtags[] = { - { aHidd_ColorMap_NumEntries, SPRITE_PEN_COUNT }, - { TAG_DONE, 0UL } - }; - HIDDT_ModeID *midp; - - D(bug("[P96Gfx] %s: Hidd Object @ 0x%p\n", __func__, o);) - data->cardData = cid; - NewList((struct List *)&data->bitmaps); - - data->spriteColors = OOP_NewObject(NULL, CLID_Hidd_ColorMap, cmtags); - OOP_GetAttr(o, aHidd_BitMap_PixFmt, (IPTR*)&data->pfo); - cid->spritepencnt = SPRITE_PEN_COUNT; - - cid->initialized = 1; - - cid->superforward = TRUE; - midp = HIDD_Gfx_QueryModeIDs(o, NULL); - for (i = 0; midp[i] != vHidd_ModeID_Invalid; i++) { - OOP_Object *sync, *pf; - HIDDT_ModeID mid = midp[i]; - IPTR dwidth, dheight; - struct RTGMode *node1, *node2; - ULONG modeid, rtgmodeid, p96mode; - - if (!HIDD_Gfx_GetMode(o, mid, &sync, &pf)) - continue; - OOP_GetAttr(sync, aHidd_Sync_HDisp, &dwidth); - OOP_GetAttr(sync, aHidd_Sync_VDisp, &dheight); - - DB2(bug("[P96Gfx] %s: w=%d h=%d mode=%08x sync=%x pf=%x\n", __func__, dwidth, dheight, mid, sync, pf);) - - modeid = vHidd_ModeID_Invalid; - ForeachNode(cid->boardinfo + PSSO_BoardInfo_ResolutionsList, r) { - if (r->Width == dwidth && r->Height == dheight) { - modeid = r->DisplayID; - break; - } - } - if (modeid == vHidd_ModeID_Invalid) { - D(bug("[P96Gfx] %s: w=%d h=%d not found!\n", __func__, dwidth, dheight);) - continue; - } - - p96mode = P96GFXRTG__GetFormat(csd, cid, pf); - rtgmodeid = (modeid & 0x00ff0000) | 0x1000 | (p96mode << 8); - - ForeachNode(&cid->rtglist, node2) { - if (node2->width == dwidth && node2->height == dheight && node2->modeid == rtgmodeid) - break; - } - if (node2->node.ln_Succ != NULL) { - D(bug("[P96Gfx] %s: w=%d h=%d mode=%08x already found!\n", __func__, dwidth, dheight, rtgmodeid);) - continue; - } - - node1 = AllocMem(sizeof(struct RTGMode), MEMF_CLEAR); - node1->width = dwidth; - node1->height = dheight; - node1->pf = pf; - node1->sync = sync; - node1->modeid = rtgmodeid; - AddTail(&cid->rtglist, &node1->node); - - DB2(bug("[P96Gfx] %s: Added %dx%d %08x %d\n", __func__, node1->width, node1->height, node1->modeid, p96mode);) - } - HIDD_Gfx_ReleaseModeIDs(o, midp); - cid->superforward = FALSE; - } - - FreeVec(restags); - FreeVec(reslist); - FreeVec(pflist); - FreeVec(modetags); - - ReturnPtr("[P96Gfx]:New", OOP_Object *, o); -} - -/********** GfxHidd::Dispose() ******************************/ -OOP_Object *P96GFXCl__Hidd_Gfx__CreateObject(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CreateObject *msg) -{ - OOP_Object *object = NULL; - - D(bug("[P96Gfx] %s()\n", __func__)); - - if (msg->cl == CSD(cl)->basebm) - { - struct p96gfx_staticdata *csd = CSD(cl); - HIDDT_ModeID modeid; - struct pHidd_Gfx_CreateObject p; - struct TagItem tags[] = - { - { TAG_IGNORE, TAG_IGNORE }, /* Placeholder for aHidd_BitMap_ClassPtr */ - { TAG_MORE, (IPTR)msg->attrList } - }; - - modeid = (HIDDT_ModeID)GetTagData(aHidd_BitMap_ModeID, vHidd_ModeID_Invalid, msg->attrList); - if (modeid != vHidd_ModeID_Invalid) { - tags[0].ti_Tag = aHidd_BitMap_ClassPtr; - tags[0].ti_Data = (IPTR)CSD(cl)->bmclass; - } - p.mID = msg->mID; - p.cl = msg->cl; - p.attrList = tags; - - object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)&p); - } - else - object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - - ReturnPtr("[P96Gfx]:CreateObject", OOP_Object *, object); -} - -VOID P96GFXCl__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - ULONG idx; - - //bug("P96GFXCl__Root__Get %x\n", msg->attrID); - - if (IS_GFX_ATTR(msg->attrID, idx)) - { - //bug("=%x\n", idx); - switch (idx) - { - case aoHidd_Gfx_HWSpriteTypes: - *msg->storage = cid->hardwaresprite ? vHidd_SpriteType_3Plus1 : 0; - return; - case aoHidd_Gfx_SupportsHWCursor: - *msg->storage = cid->hardwaresprite; - return; - case aoHidd_Gfx_NoFrameBuffer: - *msg->storage = TRUE; - return; - case aoHidd_Gfx_IsWindowed: - *msg->storage = FALSE; - return; - case aoHidd_Gfx_DriverName: - *msg->storage = (IPTR)"P96GFX"; - return; - } - } - Hidd_P96Gfx_Switch(msg->attrID, idx) - { - case aoHidd_P96Gfx_CardData: - *msg->storage = (IPTR)data->cardData; - return; - } - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); -} - -VOID P96GFXCl__Root__Set(OOP_Class *cl, OOP_Object *o, struct pRoot_Set *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - struct TagItem *tag, *tstate; - - tstate = msg->attrList; - while((tag = NextTagItem(&tstate))) - { - ULONG idx; - D(bug("[P96Gfx] %s: %x\n", __func__, tag->ti_Tag);) - if (IS_GFX_ATTR(tag->ti_Tag, idx)) { - D(bug("[P96Gfx] %s: ->%d\n", __func__, idx);) - switch(idx) - { - case aoHidd_Gfx_ActiveCallBack: - cid->acb = (void *)tag->ti_Data; - break; - - case aoHidd_Gfx_ActiveCallBackData: - cid->acbdata = (APTR)tag->ti_Data; - break; - } - } - } - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); -} -#if 0 -ULONG P96GFXCl__Hidd_Gfx__MakeViewPort(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_MakeViewPort *msg) -{ - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx] %s()\n", __func__)); - - csd->vpe = NULL; - if (!msg) - return MVP_OK; - bug("[P96Gfx] %s: %p\n", __func__, msg->Data->vpe); - csd->vpe = msg->Data->vpe; - return MVP_OK; -} - -void P96GFXCl__Hidd_Gfx__CleanViewPort(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CleanViewPort *msg) -{ - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx] %s()\n", __func__)); - - csd->vpe = NULL; -} -#endif - -static void P96GFXCl__DoShow(OOP_Class *cl, OOP_Object *o, OOP_Object *bm, struct ViewPort *vp, BOOL offonly) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - struct IntuitionBase *ib = (struct IntuitionBase*)csd->cs_IntuitionBase; - struct ViewPort *vpi = NULL; - - D(bug("[P96Gfx] %s()\n", __func__)); - - if (ib->FirstScreen) - vpi = &ib->FirstScreen->ViewPort; - - D(bug("[P96Gfx] %s: b=%p vp=%p vpi=%p acb=%p acbd=%p\n", __func__, bm, vp, vpi, cid->acb, cid->acbdata);) - - if (bm && vpi == vp) { - /* we are topmost screen -> show our display */ - IPTR tags[] = {aHidd_BitMap_Visible, TRUE, TAG_DONE}; - - if (offonly) - return; - - OOP_SetAttrs(bm, (struct TagItem *)tags); - - if (cid->acb) - cid->acb(cid->acbdata, bm); - - } else if (bm) { - /* we are not topmost -> turn off our display */ - IPTR tags[] = {aHidd_BitMap_Visible, FALSE, TAG_DONE}; - OOP_SetAttrs(bm, (struct TagItem *)tags); - } else { - - LOCK_HW - - /* no display */ - SetDisplay(cid, FALSE); - SetSwitch(cid, FALSE); - - UNLOCK_HW - } -} - -OOP_Object *P96GFXCl__Hidd_Gfx__Show(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_Show *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - - D(bug("[P96Gfx] %s()\n", __func__)); - - P96GFXCl__DoShow(cl, o, msg->bitMap, cid->viewport, FALSE); - return msg->bitMap; -} - -ULONG P96GFXCl__Hidd_Gfx__PrepareViewPorts(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_ShowViewPorts *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct HIDD_ViewPortData *vpd = msg->Data; - OOP_Object *bm = NULL; - struct ViewPort *vp = NULL; - - D(bug("[P96Gfx] %s()\n", __func__)); - - if (vpd) { - bm = vpd->Bitmap; - if (vpd->vpe) - vp = vpd->vpe->ViewPort; - } - cid->viewport = vp; - P96GFXCl__DoShow(cl, o, bm, vp, FALSE); - - D(bug("[P96Gfx] %s: viewport=%p\n", __func__, cid->viewport);) - return MCOP_OK; -} - -ULONG P96GFXCl__Hidd_Gfx__ShowViewPorts(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_ShowViewPorts *msg) -{ - struct p96gfx_staticdata *csd = CSD(cl); - struct HIDD_ViewPortData *vpd = msg->Data; - OOP_Object *bm = NULL; - struct ViewPort *vp = NULL; - - D(bug("[P96Gfx] %s()\n", __func__)); - - if (vpd) { - bm = vpd->Bitmap; - if (vpd->vpe) - vp = vpd->vpe->ViewPort; - } - P96GFXCl__DoShow(cl, o, bm, vp, FALSE); - return TRUE; -} - -VOID P96GFXCl__Hidd_Gfx__CopyBox(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CopyBox *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - HIDDT_DrawMode mode = GC_DRMD(msg->gc); - struct P96GfxBitMapData *sdata = NULL; - struct P96GfxBitMapData *ddata = NULL; - struct RenderInfo risrc, ridst; - - D(bug("[P96Gfx] %s()\n", __func__)); - - if (OOP_OCLASS(msg->src) == csd->bmclass) sdata = OOP_INST_DATA(OOP_OCLASS(msg->src), msg->src); - if (OOP_OCLASS(msg->dest) == csd->bmclass) ddata = OOP_INST_DATA(OOP_OCLASS(msg->dest), msg->dest); - - if (!sdata || !ddata) - { - DEXTRA( - bug("[P96Gfx] %s: ==== copybox: unknown bitmap %p %p drawmode %d\n", __func__, sdata, ddata, mode); - if (!sdata) bug("[P96Gfx] %s: src: %s\n", __func__, OOP_OCLASS(msg->src)->ClassNode.ln_Name ? OOP_OCLASS(msg->src)->ClassNode.ln_Name : "unknown"); - if (!ddata) bug("[P96Gfx] %s: dst: %s\n", __func__, OOP_OCLASS(msg->dest)->ClassNode.ln_Name ? OOP_OCLASS(msg->dest)->ClassNode.ln_Name : "unknown"); - ) - - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - return; - } - - if (sdata->rgbformat != ddata->rgbformat) { - DEXTRA(bug("[P96Gfx] %s: ==== copybox: format mismatch %d %d drawmode %d\n", __func__, sdata->rgbformat, ddata->rgbformat, mode);) - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - return; - } - - LOCK_MULTI_BITMAP - LOCK_BITMAP(sdata) - LOCK_BITMAP(ddata) - UNLOCK_MULTI_BITMAP - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - if (!sdata->invram || !ddata->invram) - { - /* Blit from VRAM to RAM or from RAM to VRAM */ - DEXTRA( - bug("[P96Gfx] %s: == VRAM <-> RAM blit bpp %d\n", __func__, sdata->bytesperpixel); - bug("[P96Gfx] %s: %p to %p %d,%d -> %d,%d %d x %d modulo %d %d\n", - __func__, sdata->VideoData, ddata->VideoData, - msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height, - sdata->bytesperline, - ddata->bytesperline); - ) - - if (mode == vHidd_GC_DrawMode_Copy) - { - switch(sdata->bytesperpixel) - { - case 1: - HIDD_BM_CopyMemBox8(msg->dest, - sdata->VideoData, - msg->srcX, - msg->srcY, - ddata->VideoData, - msg->destX, - msg->destY, - msg->width, - msg->height, - sdata->bytesperline, - ddata->bytesperline); - break; - - case 2: - HIDD_BM_CopyMemBox16(msg->dest, - sdata->VideoData, - msg->srcX, - msg->srcY, - ddata->VideoData, - msg->destX, - msg->destY, - msg->width, - msg->height, - sdata->bytesperline, - ddata->bytesperline); - break; - - case 3: - HIDD_BM_CopyMemBox24(msg->dest, - sdata->VideoData, - msg->srcX, - msg->srcY, - ddata->VideoData, - msg->destX, - msg->destY, - msg->width, - msg->height, - sdata->bytesperline, - ddata->bytesperline); - break; - - case 4: - HIDD_BM_CopyMemBox32(msg->dest, - sdata->VideoData, - msg->srcX, - msg->srcY, - ddata->VideoData, - msg->destX, - msg->destY, - msg->width, - msg->height, - sdata->bytesperline, - ddata->bytesperline); - break; - - } /* switch(data->bytesperpix) */ - - } /* if (mode == vHidd_GC_DrawMode_Copy) */ - else - { - DEXTRA(if (mode == vHidd_GC_DrawMode_Clear) bug("[P96Gfx] %s: clear blit %d x %d done by superclass\n", __func__, msg->width, msg->height);) - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - } - } /* if (!sdata->invram || !ddata->invram) */ - else - { - DEXTRA(if (mode == vHidd_GC_DrawMode_Clear) bug("[P96Gfx] %s: clear blit %d x %d done by me\n", __func__, msg->width, msg->height);) - - P96GFXRTG__MakeRenderInfo(csd, cid, &risrc, sdata); - P96GFXRTG__MakeRenderInfo(csd, cid, &ridst, ddata); - - LOCK_HW - - if (!BlitRectNoMaskComplete(cid, &risrc, &ridst, - msg->srcX, msg->srcY, msg->destX, msg->destY, - msg->width, msg->height, modetable[mode], sdata->rgbformat)) - { - DEXTRA(bug("[P96Gfx] %s: == unhandled blit %d x %d drawmode %d. super must help\n", __func__, msg->width, msg->height, mode);) - OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); - } - - UNLOCK_HW - } - - UNLOCK_BITMAP(sdata) - UNLOCK_BITMAP(ddata) - -} - -BOOL P96GFXCl__Hidd_Gfx__CopyBoxMasked(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CopyBoxMasked *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - - DEXTRA(bug("[P96Gfx] %s()\n", __func__)); - - LOCK_HW - WaitBlitter(cid); - UNLOCK_HW - - return OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); -} - -static UBYTE *P96GFXCl__PrepareSprite(OOP_Class *cl, OOP_Object *o, ULONG store, ULONG size, ULONG width, ULONG height, struct pHidd_Gfx_SetCursorShape *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - UBYTE *p; - - D(bug("[P96Gfx] %s()\n", __func__)); - - pb(cid->boardinfo + PSSO_BoardInfo_MouseXOffset, msg->xoffset); - pb(cid->boardinfo + PSSO_BoardInfo_MouseYOffset, msg->yoffset); - p = (UBYTE*)gp(cid->boardinfo + store); - if (p == NULL || width != cid->sprite_width || height != cid->sprite_height) { - FreeVec(p); - p = AllocVec(size, MEMF_CLEAR | MEMF_PUBLIC); - pp(cid->boardinfo + store, p); - if (!p) { - - return NULL; - } - cid->sprite_width = width; - cid->sprite_height = height; - } - return p; -} - -#ifndef MAX -#define MAX(x,y) (x)>(y)?(x):(y) -#define MIN(x,y) (x)<(y)?(x):(y) -#endif - -static UBYTE P96GFXCl__PickPen(struct p96gfx_staticdata *csd, ULONG pixel, OOP_Object *cm) -{ - UBYTE retval = 0; - ULONG diff=(ULONG)-1, tmp; - int i; - - DEXTRA(bug("[P96Gfx] %s()\n", __func__)); - - for (i = 0; i < 3; i++) { - HIDDT_Color c; - HIDD_CM_GetColor(cm, i + 1, &c); - tmp = (MAX(c.red, ((pixel & 0xFF0000) >> 16)) - MIN(c.red, ((pixel & 0xFF0000) >> 16))) + - (MAX(c.green, ((pixel & 0xFF00) >> 8)) - MIN(c.green, ((pixel & 0xFF00) >> 8))) + - (MAX(c.blue, (pixel & 0xFF)) - MIN(c.blue, (pixel & 0xFF))); - if (tmp < diff) - { - diff = tmp; - retval = i + 1; - } - } - return retval; -} - -BOOL P96GFXCl__Hidd_Gfx__SetCursorShape(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorShape *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - OOP_Object *cm = NULL; - OOP_Object *bmPFObj = NULL; - HIDDT_PixelFormat *bmPF = NULL; - IPTR pf, bmcmod, width, height; - WORD x, y, hiressprite, i; - ULONG flags; - - D(bug("[P96Gfx] %s()\n", __func__);) - - if (!(gl(cid->boardinfo + PSSO_BoardInfo_Flags ) & BIF_HARDWARESPRITE)) - return FALSE; - - OOP_GetAttr(msg->shape, aHidd_BitMap_Width, &width); - OOP_GetAttr(msg->shape, aHidd_BitMap_Height, &height); - OOP_GetAttr(msg->shape, aHidd_BitMap_ColorMap, (IPTR*)&cm); - OOP_GetAttr(msg->shape, aHidd_BitMap_PixFmt, (IPTR*)&bmPFObj); - OOP_GetAttr(bmPFObj, aHidd_PixFmt_ColorModel, &bmcmod); - if (bmcmod == vHidd_ColorModel_TrueColor) - { - OOP_GetAttr(bmPFObj, aHidd_PixFmt_StdPixFmt, (IPTR*)&pf); - bmPF = (HIDDT_PixelFormat *)HIDD_Gfx_GetPixFmt(o, pf); - } - - LOCK_HW - if (cm) { - for (i = 0; i < 3; i++) { - HIDDT_Color c; - HIDD_CM_GetColor(cm, i + 1, &c); - HIDD_P96GFX_SetCursorPen(o, i, c); - } - } - else - { - // TODO: Calculate histogram of image and choose best colors - } - - flags = gl(cid->boardinfo + PSSO_BoardInfo_Flags); - flags &= ~BIF_HIRESSPRITE; - hiressprite = 1; - if (width > 16) { - flags |= BIF_HIRESSPRITE; - hiressprite = 2; - } - pl(cid->boardinfo + PSSO_BoardInfo_Flags, flags); - - pb(cid->boardinfo + PSSO_BoardInfo_MouseWidth, width / hiressprite); - pb(cid->boardinfo + PSSO_BoardInfo_MouseHeight, height); - - Forbid(); - DB2(bug("[P96Gfx] %s: filling planar buffer ...\n", __func__);) - { - UWORD *pw; - - pw = (UWORD *)P96GFXCl__PrepareSprite(cl, o, PSSO_BoardInfo_MouseImage, 4 + 4 + ((width + 15) & ~15) / 8 * height * 2, width, height, msg); - if (!pw) - { - Permit(); - UNLOCK_HW - return FALSE; - } - pw += 2 * hiressprite; - for(y = 0; y < height; y++) { - UWORD pix1 = 0, pix2 = 0, xcnt = 0; - for(x = 0; x < width; x++) { - UBYTE c; - if (bmcmod != vHidd_ColorModel_TrueColor) - c = HIDD_BM_GetPixel(msg->shape, x, y); - else - { - HIDDT_Pixel pix = HIDD_BM_GetPixel(msg->shape, x, y); - if ((ALPHA_COMP(pix, bmPF) & 0xFF00) == 0xFF00) - c = P96GFXCl__PickPen(csd, ((RED_COMP(pix, bmPF) & 0xFF00) << 8) | (GREEN_COMP(pix, bmPF) & 0xFF00) | ((BLUE_COMP(pix, bmPF) >> 8) & 0xFF), data->spriteColors); - else c = 0; - } - pix1 <<= 1; - pix2 <<= 1; - pix1 |= (c & 1) ? 1 : 0; - pix2 |= (c & 2) ? 1 : 0; - xcnt++; - if (xcnt == 15) { - xcnt = 0; - pw[x / 16] = pix1; - pw[width / 16 + x / 16] = pix2; - } - } - pw += (width / 16) * 2; - } - } - -#if (0) - DB2(bug("[P96Gfx] %s: filling clut buffer ...\n", __func__);) - { - UBYTE *pb; - - pb = P96GFXCl__PrepareSprite(cl, o, PSSO_BoardInfo_MouseChunky, 4 + 4 + ((width + 15) & ~15) * height, width, height, msg); - if (!pb) - { - Permit(); - UNLOCK_HW - return FALSE; - } - pb += 2 * hiressprite; - for(y = 0; y < height; y++) { - for(x = 0; x < width; x++) { - UBYTE c; - if (bmcmod != vHidd_ColorModel_TrueColor) - c = HIDD_BM_GetPixel(msg->shape, x, y); - else - { - HIDDT_Pixel pix = HIDD_BM_GetPixel(msg->shape, x, y); - if ((ALPHA_COMP(pix, bmPF) & 0xFF00) == 0xFF00) - c = P96GFXCl__PickPen(csd, ((RED_COMP(pix, bmPF) & 0xFF00) << 8) | (GREEN_COMP(pix, bmPF) & 0xFF00) | ((BLUE_COMP(pix, bmPF) >> 8) & 0xFF), data->spriteColors); - else c = 0; - } - pb[x] = c; - } - pb += width; - } - } -#endif - Permit(); - - DB2(bug("[P96Gfx] %s: loading hw sprite ...\n", __func__)); - SetSpriteImage(cid); - - UNLOCK_HW - DB2(bug("[P96Gfx] %s: hw sprite loaded\n", __func__)); - - return TRUE; -} - -BOOL P96GFXCl__Hidd_Gfx__SetCursorPos(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorPos *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx] %s()\n", __func__)); - - LOCK_HW - pw(cid->boardinfo + PSSO_BoardInfo_MouseX, msg->x + (BYTE)cid->boardinfo[PSSO_BoardInfo_MouseXOffset]); - pw(cid->boardinfo + PSSO_BoardInfo_MouseY, msg->y + (BYTE)cid->boardinfo[PSSO_BoardInfo_MouseYOffset]); - SetSpritePosition(cid); - UNLOCK_HW - - return TRUE; -} - -VOID P96GFXCl__Hidd_Gfx__SetCursorVisible(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorVisible *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx] %s()\n", __func__)); - - LOCK_HW - SetSprite(cid, msg->visible); - UNLOCK_HW -} - -VOID P96GFXCl__Hidd_P96Gfx__SetCursorPen(OOP_Class *cl, OOP_Object *o, struct pHidd_P96Gfx_SetCursorPen *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - - D(bug("[P96Gfx] %s()\n", __func__)); - - HIDD_CM_SetColors(data->spriteColors, &msg->color, msg->pen, 1, data->pfo); - SetSpriteColor(cid, msg->pen, msg->color.red, msg->color.green, msg->color.blue); -} - -BOOL P96GFXCl__Hidd_Gfx__CheckMode(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CheckMode *msg) -{ - struct P96GfxData *data = OOP_INST_DATA(cl, o); - struct p96gfx_carddata *cid = data->cardData; - struct p96gfx_staticdata *csd = CSD(cl); - IPTR width, height, bpp; - - D(bug("[P96Gfx] %s()\n", __func__)); - - OOP_GetAttr(msg->sync, aHidd_Sync_HDisp, &width); - OOP_GetAttr(msg->sync, aHidd_Sync_VDisp, &height); - OOP_GetAttr(msg->pixFmt, aHidd_PixFmt_BytesPerPixel, &bpp); - if (width > cid->maxwidth[bpp]) - return FALSE; - if (height > cid->maxheight[bpp]) - return FALSE; - return width * height * bpp < cid->vram_size; -} - -/***********************************************************************************************************************************************/ -/***********************************************************************************************************************************************/ -/***************************************** Driver Probing and Initialization Functions *********************************************************/ - -static void P96GFX__FreeAttrBases(LIBBASETYPEPTR LIBBASE, struct p96gfx_staticdata *csd) -{ - OOP_ReleaseAttrBase(IID_Hidd); - OOP_ReleaseAttrBase(IID_Hidd_BitMap); - OOP_ReleaseAttrBase(IID_Hidd_BitMap_P96); - OOP_ReleaseAttrBase(IID_Hidd_GC); - OOP_ReleaseAttrBase(IID_Hidd_Sync); - OOP_ReleaseAttrBase(IID_Hidd_Gfx); - OOP_ReleaseAttrBase(IID_Hidd_P96Gfx); - OOP_ReleaseAttrBase(IID_Hidd_PixFmt); - OOP_ReleaseAttrBase(IID_Hidd_ColorMap); -} - -AROS_INTP(rtg_vblank); - -struct P96RTGmode -{ - UWORD w, h, id; - ULONG clock; - UWORD htotal, vtotal; - UWORD hborder, vborder; - UWORD hpos, vpos; - UWORD hsync, vsync; - UBYTE flags; -}; - -static const struct P96RTGmode rtgmodes[] = -{ - { 320, 240, 1, 13020000, 408, 262, 0, 0, 32, 5, 24, 1, GMF_HPOLARITY | GMF_VPOLARITY | GMF_DOUBLESCAN }, - { 640, 480, 3, 25060000, 800, 525, 0, 0, 40, 11, 88, 2, GMF_HPOLARITY | GMF_VPOLARITY }, - { 800, 600, 4, 32010000, 1024, 625, 0, 0, 56, 1, 40, 2, 0 }, - { 1024, 768, 5, 64430000, 1336, 800, 0, 0, 48, 4, 112, 5, GMF_HPOLARITY | GMF_VPOLARITY }, - { 1152, 900, 6, 85010000, 1496, 973, 0, 0, 48, 5, 40, 4, GMF_HPOLARITY | GMF_VPOLARITY }, - { 1440, 900, 7, 106360000, 1904, 932, 0, 0, 80, 0, 0, 10, GMF_HPOLARITY | GMF_VPOLARITY }, - { 0 } -}; - -/* real RTG only */ -static BOOL P96GFX__PopulateModeInfo(struct p96gfx_staticdata *csd, struct p96gfx_carddata *cid, struct LibResolution *res, const struct P96RTGmode *mode) -{ - UWORD rgbformat; - BOOL ok = FALSE; - - D(bug("[HiddP96Gfx] %s()\n", __func__);) - - for (rgbformat = 0; rgbformat < RGBFB_MaxFormats; rgbformat++) { - ULONG clockindex; - UBYTE depth, index; - struct ModeInfo *mi; - UWORD maxhval, maxvval, maxhres, maxvres; - - if (!((1 << rgbformat) & RGBFB_SUPPORTMASK)) - continue; - if (!((1 << rgbformat) & gw(cid->boardinfo + PSSO_BoardInfo_RGBFormats))) - continue; - depth = P96GFXRTG__GetDepth(1 << rgbformat); - index = (depth + 7) / 8; - if (res->Modes[index]) - continue; - - maxhval = gw(cid->boardinfo + PSSO_BoardInfo_MaxHorValue + index * 2); - maxvval = gw(cid->boardinfo + PSSO_BoardInfo_MaxVerValue + index * 2); - maxhres = gw(cid->boardinfo + PSSO_BoardInfo_MaxHorResolution + index * 2); - maxvres = gw(cid->boardinfo + PSSO_BoardInfo_MaxVerResolution + index * 2); - - if (mode->htotal > maxhval || mode->vtotal > maxvval || - mode->w > maxhres || mode->h > maxvres) - continue; - - mi = AllocMem(sizeof(struct ModeInfo), MEMF_CLEAR | MEMF_PUBLIC); - if (!mi) - continue; - mi->OpenCount = 1; - mi->Active = TRUE; - mi->Width = mode->w; - mi->Height = mode->h; - mi->Depth = depth; - mi->HorTotal = mode->htotal; - mi->VerTotal = mode->vtotal; - mi->HorBlankSize = mode->hborder; - mi->VerBlankSize = mode->vborder; - mi->HorSyncStart = mode->hpos; - mi->VerSyncStart = mode->vpos; - mi->HorSyncSize = mode->hsync; - mi->VerSyncSize = mode->vsync; - mi->Flags = mode->flags; - clockindex = ResolvePixelClock(cid, mi, mode->clock, rgbformat); - mi->PixelClock = GetPixelClock(cid, mi, clockindex, rgbformat); - DRTG(bug("[HiddP96Gfx] %s: %d,%p: %dx%dx%d ci=%d clk=%d (%d/%d)\n", - __func__, index, mi, mi->Width, mi->Height, mi->Depth, - clockindex, mi->PixelClock, mi->Numerator, mi->Denominator);) - res->Modes[index] = mi; - ok = TRUE; - } - return ok; -} - -static void P96GFX__PopulateResolutionsList(struct p96gfx_staticdata *csd, struct p96gfx_carddata *cid) -{ - struct LibResolution *node; - UWORD cnt; - - D(bug("[HiddP96Gfx] %s()\n", __func__);) - - NEWLIST((cid->boardinfo + PSSO_BoardInfo_ResolutionsList)); - for (cnt = 0; rtgmodes[cnt].clock; cnt++) { - const struct P96RTGmode *mode = &rtgmodes[cnt]; - node = AllocMem(sizeof(struct LibResolution), MEMF_CLEAR | MEMF_PUBLIC); - if (!node) - break; - node->Width = mode->w; - node->Height = mode->h; - node->DisplayID = 0x50001000 | (mode->id << 16); - node->BoardInfo = cid->boardinfo; - if (P96GFX__PopulateModeInfo(csd, cid, node, mode)) - AddTail((struct List*)(cid->boardinfo + PSSO_BoardInfo_ResolutionsList), (struct Node*)node); - else - FreeMem(node, sizeof(struct LibResolution)); - } -} - -static int P96GFX__OpenPrivateLibs(struct p96gfx_staticdata *csd) -{ - D(bug("[HiddP96Gfx] %s()\n", __func__);) - if ((csd->cs_UtilityBase = TaggedOpenLibrary(TAGGEDOPEN_UTILITY))) { - if ((csd->cs_IntuitionBase = TaggedOpenLibrary(TAGGEDOPEN_INTUITION))) { - return TRUE; - } - } - return FALSE; -} - -static void P96GFX__ClosePrivateLibs(struct p96gfx_staticdata *csd) -{ - D(bug("[HiddP96Gfx] %s()\n", __func__);) - CloseLibrary(csd->cs_IntuitionBase); - CloseLibrary(csd->cs_UtilityBase); -} - -static void P96DebugInfo(struct p96gfx_carddata *cid) -{ - UBYTE i; - DRTG(bug("[HiddP96Gfx] %s: Name:'%s'\n", __func__, - gl(cid->boardinfo + PSSO_BoardInfo_BoardName));) - DRTG(bug("[HiddP96Gfx] %s: Reg:%08x IO:%08x\n", __func__, - gl(cid->boardinfo + PSSO_BoardInfo_RegisterBase), - gl(cid->boardinfo + PSSO_BoardInfo_MemoryIOBase));) - DRTG(bug("[HiddP96Gfx] %s: BoardType:%d GCType:%d PCType:%d BPC:%d Flags:%08x\n", __func__, - gl(cid->boardinfo + PSSO_BoardInfo_BoardType), - gl(cid->boardinfo + PSSO_BoardInfo_GraphicsControllerType), - gl(cid->boardinfo + PSSO_BoardInfo_PaletteChipType), - gw(cid->boardinfo + PSSO_BoardInfo_BitsPerCannon), - gl(cid->boardinfo + PSSO_BoardInfo_Flags));) - for (i = 0; i < MAXMODES; i++) { - DRTG(bug("[HiddP96Gfx] %s: %d: HV:%4d VV: %4d HR:%4d VR:%4d C:%d\n", __func__, i, - gw(cid->boardinfo + PSSO_BoardInfo_MaxHorValue + i * 2), - gw(cid->boardinfo + PSSO_BoardInfo_MaxVerValue + i * 2), - gw(cid->boardinfo + PSSO_BoardInfo_MaxHorResolution + i * 2), - gw(cid->boardinfo + PSSO_BoardInfo_MaxVerResolution + i * 2), - gl(cid->boardinfo + PSSO_BoardInfo_PixelClockCount + i * 4));) - } -} - -struct p96gfx_carddata *P96GFX__AllocCID(struct p96gfx_staticdata *csd) -{ - struct p96gfx_carddata *cid; - struct Interrupt *intr; - - D(bug("[HiddP96Gfx] %s()\n", __func__);) - - /* Allocate the Card Instance Data */ - cid = AllocMem(sizeof(struct p96gfx_carddata), MEMF_CLEAR | MEMF_PUBLIC); - if (!cid) { - return NULL; - } - - cid->boardinfo = AllocVec(PSSO_BoardInfo_SizeOf + PSSO_BitMapExtra_Last + sizeof(struct ModeInfo), MEMF_CLEAR | MEMF_PUBLIC); - if (!cid->boardinfo) { - FreeMem(cid, sizeof(struct p96gfx_carddata)); - return NULL; - } - NEWLIST((struct List*)(cid->boardinfo + PSSO_BoardInfo_ResolutionsList)); - NEWLIST((struct List*)(cid->boardinfo + PSSO_BoardInfo_BitMapList)); - NEWLIST((struct List*)(cid->boardinfo + PSSO_BoardInfo_MemList)); - NEWLIST((struct List*)(cid->boardinfo + PSSO_BoardInfo_WaitQ)); - cid->rgbformat = (ULONG *)((IPTR)cid->boardinfo + PSSO_BoardInfo_RGBFormat); - cid->bitmapextra = cid->boardinfo + PSSO_BoardInfo_SizeOf; - cid->fakemodeinfo = (struct ModeInfo*)(cid->boardinfo + PSSO_BoardInfo_SizeOf + PSSO_BitMapExtra_Last); - pl(cid->boardinfo + PSSO_BoardInfo_BitMapExtra, (ULONG)cid->bitmapextra); - pl(cid->boardinfo + PSSO_BoardInfo_ExecBase, (ULONG)SysBase); - pl(cid->boardinfo + PSSO_BoardInfo_UtilBase, (ULONG)csd->cs_UtilityBase); - InitSemaphore((struct SignalSemaphore*)(cid->boardinfo + PSSO_BoardInfo_BoardLock)); - intr = (struct Interrupt*)(cid->boardinfo + PSSO_BoardInfo_HardInterrupt); - intr->is_Code = (APTR)rtg_vblank; - intr->is_Data = cid->boardinfo; - intr->is_Node.ln_Name = "RTG VBlank"; - intr->is_Node.ln_Pri = 0; - intr->is_Node.ln_Type = NT_INTERRUPT; - intr = (struct Interrupt*)(cid->boardinfo + PSSO_BoardInfo_SoftInterrupt); - intr->is_Code = (APTR)rtg_vblank; - intr->is_Data = cid->boardinfo; - intr->is_Node.ln_Name = "RTG VBlank"; - intr->is_Node.ln_Pri = 0; - intr->is_Node.ln_Type = NT_INTERRUPT; - - return cid; -} - -VOID P96GFX__FreeCID(struct p96gfx_staticdata *csd, struct p96gfx_carddata *cid) -{ - D(bug("[HiddP96Gfx] %s()\n", __func__);) - if (cid->vmem) - FreeMem(cid->vmem, sizeof(struct MemHeader)); - FreeVec(cid->boardinfo); - FreeVec(cid->boardinfo); - FreeMem(cid, sizeof(struct p96gfx_carddata)); -} - -VOID P96GFX__FreeCardCIDList(struct p96gfx_staticdata *csd) -{ - D(bug("[HiddP96Gfx] %s()\n", __func__);) -} - -static BOOL P96GFX__InitCard(struct p96gfx_staticdata *csd, struct Library *lib) -{ - struct p96gfx_carddata *cid; - DRTG(bug("[HiddP96Gfx] %s: attempting to init '%s'\n", __func__, lib->lib_Node.ln_Name);) - - cid = P96GFX__AllocCID(csd); - if (!cid) - return FALSE; - - pl(cid->boardinfo + PSSO_BoardInfo_CardBase, (ULONG)lib); - cid->CardBase = lib; - P96GFXRTG__Init(cid->boardinfo); - if (FindCard(cid)) { - DRTG(bug("[HiddP96Gfx] %s: FindCard succeeded\n", __func__);) - if (InitCard(cid)) { - DRTG(bug("[HiddP96Gfx] %s: InitCard succeeded\n", __func__);) - SetInterrupt(cid, FALSE); - /* Without this, the card may not be in linear memory map mode. */ - SetMemoryMode(cid, RGBFB_CLUT); - P96DebugInfo(cid); - AddTail(&csd->foundCards, &cid->p96gfx_Node); - P96GFX__PopulateResolutionsList(csd, cid); - cid->hardwaresprite = gl(cid->boardinfo + PSSO_BoardInfo_Flags) & (1 << BIB_HARDWARESPRITE); - return TRUE; - } - } - pl(cid->boardinfo + PSSO_BoardInfo_CardBase, 0); - P96GFX__FreeCID(csd, cid); - return FALSE; -} - - -BOOL P96GFX__Initialise(LIBBASETYPEPTR LIBBASE) -{ - struct p96gfx_staticdata *csd = &LIBBASE->csd; - struct Library *GfxBase = csd->cs_GfxBase; - struct p96gfx_carddata *cid; - struct MemChunk *mc; - struct Interrupt *intr; - struct Node *node; - UBYTE i; - BOOL retval = FALSE; - - D(bug("[HiddP96Gfx] %s()\n", __func__);) - - if (!(SysBase->AttnFlags & AFF_68020)) - return retval; - - if (!P96GFX__OpenPrivateLibs(csd)) { - P96GFX__ClosePrivateLibs(csd); - return retval; - } - - NEWLIST(&csd->foundCards); - D(bug("[HiddP96Gfx] %s: cardlist @ 0x%p\n", __func__, &csd->foundCards);) - - /* find available p96 '.card' drivers .. */ - Forbid(); - ForeachNode(&SysBase->LibList.lh_Head, node) { - struct Library *lib = (struct Library*)node; - char *name = node->ln_Name; - int len = strlen(name); - if (len > 5 && !stricmp(name + len - 5, ".card")) { - Permit(); - retval = P96GFX__InitCard(csd, lib); - Forbid(); - DRTG( - if (!retval) - bug("[HiddP96Gfx] %s: %s init failed\n", __func__, name); - ) - } - } - Permit(); - - /* if none where found create the p96 romvector entry if available */ - if (IsListEmpty(&csd->foundCards)) { - cid = P96GFX__AllocCID(csd); - if (cid) - { - cid->p96romvector = (APTR)(0xf00000 + 0xff60); - if ((gl(cid->p96romvector) & 0xff00ffff) != 0xa0004e75) { - D(bug("[HiddP96Gfx] %s: P96 boot ROM entry point not found. P96GFX not enabled.\n", __func__);) - P96GFX__FreeCID(csd, cid); - P96GFX__ClosePrivateLibs(csd); - return retval; - } - if (!FindCard(cid)) { - D(bug("[HiddP96Gfx] %s: P96 FindCard() returned false\n", __func__);) - P96GFX__FreeCID(csd, cid); - P96GFX__ClosePrivateLibs(csd); - return retval; - } - D(bug("[HiddP96Gfx] %s: P96 FindCard done\n", __func__);) - InitCard(cid); - cid->hardwaresprite = (gl(cid->boardinfo + PSSO_BoardInfo_Flags) & (1 << BIB_HARDWARESPRITE)) && SetSprite(cid, FALSE); - AddTail(&csd->foundCards, &cid->p96gfx_Node); - } - } - - /* if we have found suitable drivers that have registered resolutions, setup the cards memory */ - ForeachNode(&csd->foundCards, cid) { - if (IsListEmpty((struct List*)(cid->boardinfo + PSSO_BoardInfo_ResolutionsList))) { - continue; - } - retval = TRUE; - for (i = 0; i < MAXMODES; i++) { - cid->maxwidth[i] = gw(cid->boardinfo + PSSO_BoardInfo_MaxHorResolution + i * 2); - cid->maxheight[i] = gw(cid->boardinfo + PSSO_BoardInfo_MaxVerResolution + i * 2); - } - - D(bug("[HiddP96Gfx] %s: InitCard done\n", __func__);) - - DRTG(bug("[HiddP96Gfx] %s: hardware sprite: %d\n", __func__, cid->hardwaresprite);) - - cid->vram_start = (UBYTE*)gl(cid->boardinfo + PSSO_BoardInfo_MemoryBase); - -#ifdef USE_VRAM_HACK - /* REMOVE-ME: 4MB hack (used for easier debug of vram <-> ram swapping) !!!!*/ - cid->vram_size = 4 * 1024 * 1024; /* gl(cid->boardinfo + PSSO_BoardInfo_MemorySize); */ -#else - cid->vram_size = gl(cid->boardinfo + PSSO_BoardInfo_MemorySize); -#endif - - DRTG(bug("[HiddP96Gfx] %s: P96RTG VRAM found at %08x size %08x\n", __func__, cid->vram_start, cid->vram_size);) - mc = (struct MemChunk*)cid->vram_start; - cid->vmem = AllocVec(sizeof(struct MemHeader), MEMF_CLEAR | MEMF_PUBLIC); - cid->vmem->mh_Node.ln_Type = NT_MEMORY; - cid->vmem->mh_First = mc; - cid->vmem->mh_Lower = (APTR)mc; - cid->vmem->mh_Upper = (APTR)((ULONG)mc + cid->vram_size); - cid->vmem->mh_Free = cid->vram_size; - mc->mc_Next = NULL; - mc->mc_Bytes = cid->vmem->mh_Free; - } - if (!retval) - { - // We dont fail if atleast one card successfully built its resolution list. - D(bug("[HiddP96Gfx] %s: Resolutionlist(s) empty, init failed.\n", __func__);) - P96GFX__FreeCardCIDList(csd); - P96GFX__ClosePrivateLibs(csd); - return retval; - } - - D(bug("[HiddP96Gfx] %s: initialising common data ..\n", __func__);) - - retval = FALSE; - - __IHidd = OOP_ObtainAttrBase(IID_Hidd); - __IHidd_BitMap = OOP_ObtainAttrBase(IID_Hidd_BitMap); - __IHidd_BitMap_P96 = OOP_ObtainAttrBase(IID_Hidd_BitMap_P96); - __IHidd_GC = OOP_ObtainAttrBase(IID_Hidd_GC); - __IHidd_Sync = OOP_ObtainAttrBase(IID_Hidd_Sync); - __IHidd_Gfx = OOP_ObtainAttrBase(IID_Hidd_Gfx); - __IHidd_P96Gfx = OOP_ObtainAttrBase(IID_Hidd_P96Gfx); - __IHidd_PixFmt = OOP_ObtainAttrBase(IID_Hidd_PixFmt); - __IHidd_ColorMap = OOP_ObtainAttrBase(IID_Hidd_ColorMap); - - HiddBitMapBase = OOP_GetMethodID(IID_Hidd_BitMap, 0); - HiddColorMapBase = OOP_GetMethodID(IID_Hidd_ColorMap, 0); - HiddGfxBase = OOP_GetMethodID(IID_Hidd_Gfx, 0); - HiddP96GfxBase = OOP_GetMethodID(IID_Hidd_P96Gfx, 0); - - if (!__IHidd || !__IHidd_BitMap || !__IHidd_BitMap_P96 || !__IHidd_GC || - !__IHidd_Sync || !__IHidd_Gfx || !__IHidd_P96Gfx || !__IHidd_PixFmt || - !__IHidd_ColorMap) - { - D(bug("[HiddP96Gfx] %s: failed to obtain attribute bases!\n", __func__);) - P96GFX__FreeAttrBases(LIBBASE, csd); - P96GFX__FreeCardCIDList(csd); - P96GFX__ClosePrivateLibs(csd); - return retval; - } - - D(bug("[HiddP96Gfx] %s: registering found cards ...\n", __func__);) - ULONG driverres; - ForeachNode(&csd->foundCards, cid) { - D(bug("[HiddP96Gfx] %s: carddata @ 0x%p\n", __func__, cid);) - - /* fake an opener for every card instance */ - LIBBASE->library.lib_OpenCnt += 1; - - cid->p96gfxcd_Tags = AllocVec((sizeof(struct TagItem) << 1), MEMF_PUBLIC | MEMF_CLEAR); - if (cid->p96gfxcd_Tags) - { - D(bug("[HiddP96Gfx] %s: tags @ 0x%p\n", __func__, cid->p96gfxcd_Tags);) - cid->p96gfxcd_Tags[0].ti_Tag = aHidd_P96Gfx_CardData; - cid->p96gfxcd_Tags[0].ti_Data = (IPTR)cid; - if (DD_OK == (driverres = AddDisplayDriver(csd->gfxclass, cid->p96gfxcd_Tags, - DDRV_KeepBootMode, TRUE, - DDRV_IDMask , 0xF0000000, - TAG_DONE))) - { - D(bug("[HiddP96Gfx] %s: AddDisplayDriver succeeded\n", __func__);) - retval = TRUE; - } - else - { - bug("[HiddP96Gfx] AddDisplayDriver failed - %08x\n", driverres); - } - } - } - DRTG(bug("[HiddP96Gfx] %s: P96GFX init done\n", __func__);) - return retval; -} - -static int P96GFX_LibExpunge(LIBBASETYPEPTR LIBBASE) -{ - struct p96gfx_staticdata *csd = &LIBBASE->csd; - int retval = FALSE; - - D(bug("[HiddP96Gfx] %s()\n", __func__);) - - if (LIBBASE->library.lib_OpenCnt == 0) - { - P96GFX__FreeAttrBases(LIBBASE, csd); - P96GFX__ClosePrivateLibs(csd); - retval = TRUE; - } - return retval; -} - -ADD2EXPUNGELIB(P96GFX_LibExpunge, 1) - -#undef SysBase - -AROS_INTH1(rtg_vblank, APTR, boardinfo) -{ - AROS_INTFUNC_INIT - - return 0; - - AROS_INTFUNC_EXIT -} diff --git a/arch/m68k-amiga/hidd/p96gfx/p96gfx_intern.h b/arch/m68k-amiga/hidd/p96gfx/p96gfx_intern.h deleted file mode 100644 index 4f526f1342..0000000000 --- a/arch/m68k-amiga/hidd/p96gfx/p96gfx_intern.h +++ /dev/null @@ -1,131 +0,0 @@ -#ifndef P96GFX_INTERN_H -#define P96GFX_INTERN_H - -#include -#include -#include - -#include - -struct RTGMode -{ - struct Node node; - ULONG modeid; - UWORD width, height; - OOP_Object *pf; - OOP_Object *sync; -}; - -struct p96gfx_staticdata -{ - struct ExecBase *cs_SysBase; - struct Library *cs_GfxBase; - struct Library *cs_IntuitionBase; - struct Library *cs_UtilityBase; - struct Library *cs_OOPBase; - - IPTR cs_SegList; - - OOP_Class *basebm; /* baseclass for CreateObject */ - OOP_Class *gfxclass; - OOP_Class *bmclass; - - OOP_AttrBase hiddAttrBase; - OOP_AttrBase hiddBitMapAttrBase; - OOP_AttrBase hiddP96GFXBitMapAttrBase; - OOP_AttrBase hiddGCAttrBase; - OOP_AttrBase hiddSyncAttrBase; - OOP_AttrBase hiddPixFmtAttrBase; - OOP_AttrBase hiddGfxAttrBase; - OOP_AttrBase hiddP96GfxAttrBase; - OOP_AttrBase hiddColorMapAttrBase; - - OOP_MethodID hiddBitMapBase; - OOP_MethodID hiddColorMapBase; - OOP_MethodID hiddGfxBase; - OOP_MethodID hiddP96GfxBase; - - struct List foundCards; -}; - -struct p96gfx_carddata -{ - struct Node p96gfx_Node; - struct TagItem *p96gfxcd_Tags; - char *p96gfx_HWName; - char *p96gfx_HWResTmplt; - - struct List rtglist; - struct List bitmaplist; - struct Library *CardBase; - - struct P96GfxBitMapData *disp; - APTR p96romvector; - ULONG *rgbformat; - struct ModeInfo *modeinfo; - struct ModeInfo *fakemodeinfo; - UBYTE *boardinfo; - UBYTE *bitmapextra; - UBYTE *vram_start; - ULONG vram_size; - ULONG vram_used, fram_used; - struct MemHeader *vmem; - - WORD sprite_width, sprite_height; - BOOL hardwaresprite; - WORD spritepencnt; - - BOOL initialized; - BOOL superforward; - - UWORD dwidth, dheight; - ULONG dmodeid; - - UWORD maxwidth[5]; - UWORD maxheight[5]; - - struct ViewPort *viewport; - void (*acb)(void *data, void *bm); - APTR acbdata; - - struct SignalSemaphore HWLock; - struct SignalSemaphore MultiBMLock; -}; - -struct P96GFXclbase -{ - struct Library library; - - struct p96gfx_staticdata csd; -}; - -#undef CSD -#define CSD(cl) (&((struct P96GFXclbase *)cl->UserData)->csd) - -#define SysBase (csd->cs_SysBase) -#define OOPBase (csd->cs_OOPBase) -#define UtilityBase (csd->cs_UtilityBase) - -#define __IHidd (csd->hiddAttrBase) -#define __IHidd_BitMap (csd->hiddBitMapAttrBase) -#define __IHidd_BitMap_P96 (csd->hiddP96GFXBitMapAttrBase) -#define __IHidd_GC (csd->hiddGCAttrBase) -#define __IHidd_Sync (csd->hiddSyncAttrBase) -#define __IHidd_PixFmt (csd->hiddPixFmtAttrBase) -#define __IHidd_Gfx (csd->hiddGfxAttrBase) -#define __IHidd_P96Gfx (csd->hiddP96GfxAttrBase) -//#define __IHidd_Attr (csd->hiddAttrBase) -#define __IHidd_ColorMap (csd->hiddColorMapAttrBase) - -#define HiddBitMapBase (csd->hiddBitMapBase) -#define HiddColorMapBase (csd->hiddColorMapBase) -#define HiddGfxBase (csd->hiddGfxBase) -#define HiddP96GfxBase (csd->hiddP96GfxBase) - -#define LOCK_HW {ObtainSemaphore(&(cid)->HWLock);} -#define UNLOCK_HW {ReleaseSemaphore(&(cid)->HWLock);} - -#define LOCK_MULTI_BITMAP {ObtainSemaphore(&(cid)->MultiBMLock);} -#define UNLOCK_MULTI_BITMAP {ReleaseSemaphore(&(cid)->MultiBMLock);} - -#endif diff --git a/arch/m68k-amiga/hidd/p96gfx/p96gfx_rtg.c b/arch/m68k-amiga/hidd/p96gfx/p96gfx_rtg.c deleted file mode 100644 index 0e229e0ed7..0000000000 --- a/arch/m68k-amiga/hidd/p96gfx/p96gfx_rtg.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. - $Id$ - - Desc: p96 RTG support code. -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include "p96gfx_intern.h" -#include "p96gfx_bitmap.h" -#include "p96gfx_rtg.h" -#include "p96call.h" - -const UBYTE modetable[16] = - { 0, 8, 4, 12, 2, 10, 6, 14, 7, 9, 5, 13, 3, 11, 1, 15 }; - -static AROS_UFH1(ULONG, RTGCall_Default, - AROS_UFHA(APTR, boardinfo, A0)) -{ - AROS_USERFUNC_INIT - - pw (boardinfo + PSSO_BoardInfo_AROSFlag, 0); - return 0; - - AROS_USERFUNC_EXIT -} - -/* Set fallback functions */ -void P96GFXRTG__Init(APTR boardinfo) -{ - UWORD i; - - for (i = PSSO_BoardInfo_AllocCardMem; i <= PSSO_BoardInfo_DeleteFeature; i += 4) - pl(boardinfo + i, (ULONG)RTGCall_Default); -} - -WORD P96GFXRTG__GetDepth(ULONG rgbformat) -{ - if (rgbformat & RGBFF_CLUT) - return 8; - if (rgbformat & (RGBFF_R5G5B5PC | RGBFF_R5G5B5 | RGBFF_B5G5R5PC)) - return 15; - if (rgbformat & (RGBFF_R5G6B5PC | RGBFF_R5G6B5 | RGBFF_B5G6R5PC)) - return 16; - if (rgbformat & (RGBFF_R8G8B8 | RGBFF_B8G8R8)) - return 24; - if (rgbformat & (RGBFF_A8R8G8B8 | RGBFF_A8B8G8R8 | RGBFF_R8G8B8A8 | RGBFF_B8G8R8A8)) - return 32; - return 0; -} - -ULONG P96GFXRTG__GetFormat(struct p96gfx_staticdata *csd, struct p96gfx_carddata *cid, OOP_Object *pixfmt) -{ - IPTR depth, redmask, bluemask, endianswitch; - - OOP_GetAttr(pixfmt, aHidd_PixFmt_Depth, &depth); - OOP_GetAttr(pixfmt, aHidd_PixFmt_RedMask, &redmask); - OOP_GetAttr(pixfmt, aHidd_PixFmt_BlueMask, &bluemask); - OOP_GetAttr(pixfmt, aHidd_PixFmt_SwapPixelBytes, &endianswitch); - - if (depth == 8) - return RGBFB_CLUT; - if (depth == 15) { - if (redmask == 0x00007c00 && !endianswitch) - return RGBFB_R5G5B5; - if (redmask == 0x00007c00 && endianswitch) - return RGBFB_R5G5B5PC; - if (redmask == 0x0000003e && bluemask == 0x0000f800) - return RGBFB_B5G5R5PC; - } - if (depth == 16) { - if (redmask == 0x0000f800 && !endianswitch) - return RGBFB_R5G6B5; - if (redmask == 0x0000f800 && endianswitch) - return RGBFB_R5G6B5PC; - if (redmask == 0x0000001f && bluemask == 0x0000f800) - return RGBFB_B5G6R5PC; - } - if (depth == 32) { - if (redmask == 0x0000ff00) - return RGBFB_B8G8R8A8; - if (redmask == 0xff000000) - return RGBFB_R8G8B8A8; - if (redmask == 0x000000ff) - return RGBFB_A8B8G8R8; - if (redmask == 0x00ff0000) - return RGBFB_A8R8G8B8; - } else if (depth == 24) { - if (redmask == 0x000000ff) - return RGBFB_B8G8R8; - if (redmask == 0x00ff0000) - return RGBFB_R8G8B8; - } - D(bug("P96GFXRTG__GetFormat RGBFB_NONE!? %d %08x %08x\n", depth, redmask, bluemask)); - return RGBFB_NONE; -} - -void P96GFXRTG__MakeRenderInfo(struct p96gfx_staticdata *csd, struct p96gfx_carddata *cid, struct RenderInfo *ri, struct P96GfxBitMapData *bm) -{ - ri->Memory = bm->VideoData; - ri->BytesPerRow = bm->bytesperline; - ri->RGBFormat = bm->rgbformat; -} - -struct ModeInfo *P96GFXRTG__GetModeInfo(struct p96gfx_staticdata *csd, struct p96gfx_carddata *cid, OOP_Object *sync, OOP_Object *pixfmt, struct ModeInfo *modeinfo) -{ - struct LibResolution *node; - IPTR width, height, depth; - - OOP_GetAttr(sync, aHidd_Sync_HDisp, &width); - OOP_GetAttr(sync, aHidd_Sync_VDisp, &height); - OOP_GetAttr(pixfmt, aHidd_PixFmt_Depth, &depth); - - D(bug("P96GFXRTG__GetModeInfo %dx%dx%d\n", width, height, depth)); - // P96 RTG driver does not need anything else - // but real RTG does - ForeachNode((cid->boardinfo + PSSO_BoardInfo_ResolutionsList), node) { - if (node->Width == width && node->Height == height) { - UBYTE index = (depth + 7) / 8; - if (node->Modes[index]) { - D(bug("RTG ModeInfo found %p\n", node->Modes[index])); - return node->Modes[index]; - } - } - } - D(bug("using fake modeinfo\n")); - modeinfo->Width = width; - modeinfo->Height = height; - modeinfo->Depth = depth; - return modeinfo; -} diff --git a/arch/m68k-amiga/hidd/p96gfx/p96gfx_startup.c b/arch/m68k-amiga/hidd/p96gfx/p96gfx_startup.c deleted file mode 100644 index 207531e90d..0000000000 --- a/arch/m68k-amiga/hidd/p96gfx/p96gfx_startup.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright © 1995-2019, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#define DEBUG 0 - -#include -#include -#include -#include -#include -#include -#include - -#include "p96gfx_intern.h" -#include "p96gfx_bitmap.h" - -#include LC_LIBDEFS_FILE - -BOOL P96GFX__Initialise(LIBBASETYPEPTR LIBBASE); - -#undef SysBase -#undef OOPBase - -static int P96GFX_LibInit(LIBBASETYPEPTR LIBBASE) -{ - struct ExecBase *SysBase = LIBBASE->csd.cs_SysBase; - struct Library *OOPBase = LIBBASE->csd.cs_OOPBase; - LIBBASE->csd.cs_GfxBase = TaggedOpenLibrary(TAGGEDOPEN_GRAPHICS); - struct Library *GfxBase = LIBBASE->csd.cs_GfxBase; - - D(bug("[HiddP96Gfx] %s() ******************************\n", __func__)); - - if (!GfxBase) - return FALSE; - - LIBBASE->csd.basebm = OOP_FindClass(CLID_Hidd_BitMap); - - if (!P96GFX__Initialise(LIBBASE)) { - D(bug("[HiddP96Gfx] %s: P96GFX__Initialise failed\n", __func__)); - CloseLibrary(GfxBase); - return FALSE; - } - - return TRUE; -} -ADD2INITLIB(P96GFX_LibInit, 0) diff --git a/arch/m68k-amiga/hidd/uaegfx/mmakefile.src b/arch/m68k-amiga/hidd/uaegfx/mmakefile.src new file mode 100644 index 0000000000..009a77814a --- /dev/null +++ b/arch/m68k-amiga/hidd/uaegfx/mmakefile.src @@ -0,0 +1,14 @@ +# $Id$ + +include $(SRCDIR)/config/aros.cfg + +USER_CPPFLAGS := \ + -D__OOP_NOATTRBASES__ \ + -D__GRAPHICS_NOHIDDBASE__ \ + -D__UTILITY_NOLIBBASE__ \ + -D__GRAPHICS_NOLIBBASE__ \ + -D__OOP_NOLIBBASE__ + +%build_module mmake=kernel-amiga-m68k-uaegfx \ + modname=uaegfx modtype=hidd \ + files="startup uaegfx_hiddclass uaegfx_bitmapclass uaertg" diff --git a/arch/m68k-amiga/hidd/uaegfx/p96call.c b/arch/m68k-amiga/hidd/uaegfx/p96call.c new file mode 100644 index 0000000000..e41b1db356 --- /dev/null +++ b/arch/m68k-amiga/hidd/uaegfx/p96call.c @@ -0,0 +1,133 @@ +/* + Copyright © 1995-2001, The AROS Development Team. All rights reserved. + $Id$ +*/ +/* This program generates the p96call.h macroset for gcc-4.5.1 m68k-elf + * + * WARNING: The header generated by this program is designed + * to work with GCC 4.5.1 m68k-elf ONLY, and even + * then it has only been very lightly tested with + * "-O2 -fomit-frame-pointer -ffixed-a6" + * + * If it breaks, you get to keep both pieces. + */ + +#include + +#define GENCALL_MAX (13 + 1) /* Max number of arguments */ + +static void asm_regs_init(int id, int has_bn, const char *jmp, const char *addr) +{ + int i; + + /* Input values */ + for (i = 0; i < id; i++) + printf("\t ULONG _arg%d = (ULONG)__AROS_LCA(a%d); \\\n", + i + 1, i + 1); + if (has_bn) + printf("\t ULONG _bn_arg = (ULONG)bn; \\\n"); + + /* Define registers */ + printf("\t register volatile ULONG _ret asm(\"%%d0\"); \\\n"); + for (i = 0; i < id; i++) + printf("\t register volatile ULONG __AROS_LTA(a%d) asm(__AROS_LSA(a%d)); \\\n", + i + 1, i + 1); + if (has_bn) + printf("\t register volatile ULONG _bn asm(\"%%a6\"); \\\n"); + + + /* Set registers (non FP) */ + for (i = 1; i <= id; i++) + printf("\t if (! __AROS_ISREG(a%d,__AROS_FP_REG)) { \\\n" + "\t __AROS_LTA(a%d) = _arg%d; } \\\n", + i, i, i); + if (has_bn) + printf("\t if (! __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)) { \\\n" + "\t _bn = _bn_arg; } \\\n"); + + /* Set FP register */ + for (i = 1; i <= id; i++) { + int j; + printf("\t if ( __AROS_ISREG(a%d,__AROS_FP_REG)) { \\\n" + "\t asm volatile (\"move.l %%%%\" __AROS_FP_SREG \",%%%%sp@-\\nmove.l %%0,%%%%\" __AROS_FP_SREG \"\\n%s\\nmove.l %%%%sp@+,%%%%\" __AROS_FP_SREG \"\\n\" : : \"r\" (_arg%d), %s \\\n", + i, jmp, i, addr); + for (j = 0; j < id; j++) + printf("\t\t, \"r\" (__AROS_LTA(a%d)) \\\n", j + 1); + printf("\t ); }\\\n"); + } + if (has_bn) { + int j; + printf("\t if ( __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)) { \\\n" + "\t asm volatile (\"move.l %%%%\" __AROS_FP_SREG \",%%%%sp@-\\nmove.l %%0,%%%%\" __AROS_FP_SREG \"\\n%s\\nmove.l %%%%sp@+,%%%%\" __AROS_FP_SREG \"\\n\" : : \"r\" (_bn_arg), %s \\\n", jmp, addr); + for (j = 0; j < id; j++) + printf("\t\t, \"r\" (__AROS_LTA(a%d)) \\\n", j + 1); + printf("\t ); }\\\n"); + } + if (has_bn || id > 0) { + int j; + printf("\t if (!(0"); + if (has_bn) + printf(" || __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)"); + for (i = 0; i < id; i++) + printf(" || __AROS_ISREG(a%d,__AROS_FP_REG)", i+1); + printf(")) {\\\n" + "\t asm volatile (\"%s\\n\" : : \"i\" (0), %s \\\n", jmp, addr); + for (j = 0; j < id; j++) + printf("\t\t, \"r\" (__AROS_LTA(a%d)) \\\n", j + 1); + printf("\t ); }\\\n"); + } +} + +static void asm_regs_exit(int id, int has_bn) +{ + /* Get the return code */ + printf("\t asm volatile (\"\" : \"=r\" (_ret) : : \"%%a0\", \"%%a1\", \"%%d1\", \"cc\", \"memory\"); \\\n"); + + /* Save retval */ + printf("\t (t)_ret; \\\n"); +} + +static void p96_lc(int id) +{ + int i; + char jmp[256]; + + printf("#define P96_LC%d(t,vector,id", id); + for (i = 0; i < id; i++) + printf(",a%d", i + 1); + printf(") \\\n"); + printf("\t({ APTR _n = (vector);\\\n"); + snprintf(jmp, sizeof(jmp), "move.l %%3,%%%%sp@-\\n" + "pea.l .Lufc%d_%%c2\\n" + "move.l %%1, %%%%sp@-\\n" + "rts\\n" + ".Lufc%d_%%c2:\\n" + "addq.l #4,%%%%sp\\n" + , id, id); + jmp[sizeof(jmp)-1]=0; + asm_regs_init(i, 0, jmp, "\"r\" (_n), \"i\" (__LINE__), \"i\" (id)"); + + asm_regs_exit(i, 0); + printf("\t })\n\n"); +} + +int main(int argc, char **argv) +{ + int i; + + printf("/* AUTOGENERATED by p96call.c */\n"); + printf("/* If you can get this to work for anything other */\n"); + printf("/* than gcc-4.5.1 m68k-elf, it would be surprising. */\n"); + printf("\n"); + printf("#ifndef P96CALL_H\n"); + printf("#define P96CALL_H\n"); + printf("\n"); + printf("/* Call a P96 function */\n"); + printf("\n"); + + for (i = 0; i < GENCALL_MAX; i++) + p96_lc(i); + + printf("#endif /* P96CALL_H */\n"); + return 0; +} diff --git a/arch/m68k-amiga/hidd/p96gfx/p96call.h b/arch/m68k-amiga/hidd/uaegfx/p96call.h similarity index 100% rename from arch/m68k-amiga/hidd/p96gfx/p96call.h rename to arch/m68k-amiga/hidd/uaegfx/p96call.h diff --git a/arch/m68k-amiga/hidd/uaegfx/startup.c b/arch/m68k-amiga/hidd/uaegfx/startup.c new file mode 100644 index 0000000000..e957f36e2e --- /dev/null +++ b/arch/m68k-amiga/hidd/uaegfx/startup.c @@ -0,0 +1,58 @@ +/* + Copyright © 1995-2017, The AROS Development Team. All rights reserved. + $Id$ +*/ + +#define DEBUG 0 + +#include +#include +#include +#include +#include +#include +#include + +#include "uaegfx_intern.h" +#include "uaegfx_bitmap.h" + +#include LC_LIBDEFS_FILE + +BOOL Init_UAEGFXClass(LIBBASETYPEPTR LIBBASE); + +#undef SysBase +#undef OOPBase + +static int UAEGFX_Init(LIBBASETYPEPTR LIBBASE) +{ + ULONG err; + struct ExecBase *SysBase = LIBBASE->csd.cs_SysBase; + struct Library *GfxBase = TaggedOpenLibrary(TAGGEDOPEN_GRAPHICS); + struct Library *OOPBase = OpenLibrary("oop.library", 0); + + D(bug("************************* UAEGFX_Init ******************************\n")); + + if (!GfxBase) + return FALSE; + + LIBBASE->csd.basebm = OOP_FindClass(CLID_Hidd_BitMap); + CloseLibrary(OOPBase); + + if (!Init_UAEGFXClass(LIBBASE)) { + CloseLibrary(GfxBase); + return FALSE; + } + + LIBBASE->library.lib_OpenCnt = 1; + + err = AddDisplayDriver(LIBBASE->csd.gfxclass, NULL, + DDRV_KeepBootMode, TRUE, + DDRV_IDMask , 0xF0000000, + TAG_DONE); + + CloseLibrary(GfxBase); + + D(bug("UAEGFXHIDD AddDisplayDriver() result: %u\n", err)); + return err ? FALSE : TRUE; +} +ADD2INITLIB(UAEGFX_Init, 0) diff --git a/arch/m68k-amiga/hidd/p96gfx/p96gfx.conf b/arch/m68k-amiga/hidd/uaegfx/uaegfx.conf similarity index 53% rename from arch/m68k-amiga/hidd/p96gfx/p96gfx.conf rename to arch/m68k-amiga/hidd/uaegfx/uaegfx.conf index 6d447aa9a9..95ae67956a 100644 --- a/arch/m68k-amiga/hidd/p96gfx/p96gfx.conf +++ b/arch/m68k-amiga/hidd/uaegfx/uaegfx.conf @@ -1,22 +1,22 @@ ##begin config -basename P96GFXCl -libbase P96GFXClBase -libbasetype struct P96GFXclbase -version 45.3 +basename UAEGFXCl +libbase UAEGFXClBase +libbasetype struct UAEGFXclbase +version 45.0 residentpri -10 -classid CLID_Hidd_Gfx_P96 +classid CLID_Hidd_Gfx_UAE superclass CLID_Hidd_Gfx classptr_field csd.gfxclass -classdatatype struct P96GfxData -seglist_field csd.cs_SegList +classdatatype struct gfx_data +seglist_field cs_SegList sysbase_field csd.cs_SysBase oopbase_field csd.cs_OOPBase ##end config ##begin cdefprivate #include -#include "p96gfx_hidd.h" -#include "p96gfx_bitmap.h" +#include "uaegfx_intern.h" +#include "uaegfx_bitmap.h" ##end cdefprivate @@ -40,18 +40,16 @@ NextModeID QueryModeIDs ReleaseModeIDs GetMode -.interface Hidd_P96Gfx -SetCursorPen ##end methodlist ##begin class ##begin config -basename P96GFXBitmap +basename UAEGFXBitmap type hidd superclass CLID_Hidd_BitMap classptr_field csd.bmclass -classdatatype struct P96GfxBitMapData +classdatatype struct bm_data ##end config ##begin methodlist @@ -77,22 +75,3 @@ ObtainDirectAccess ReleaseDirectAccess ##end methodlist ##end class - -##begin interface -##begin config -interfaceid hidd.gfx.p96gfx -interfacename Hidd_P96Gfx -methodstub HIDD_P96GFX -methodbase HiddP96GfxBase -attributebase HiddP96GfxAttrBase -##end config - - -##begin attributelist -APTR CardData # [..G] Private card data -##end attributelist - -##begin methodlist -VOID SetCursorPen(UWORD pen, HIDDT_Color color) -##end methodlist -##end interface diff --git a/arch/m68k-amiga/hidd/uaegfx/uaegfx_bitmap.h b/arch/m68k-amiga/hidd/uaegfx/uaegfx_bitmap.h new file mode 100644 index 0000000000..5d2a0ac3d2 --- /dev/null +++ b/arch/m68k-amiga/hidd/uaegfx/uaegfx_bitmap.h @@ -0,0 +1,37 @@ +/* + Copyright 1995-2017, The AROS Development Team. All rights reserved. + $Id$ +*/ + +#ifndef _UAEGFXBITMAP_H +#define _UAEGFXBITMAP_H + +#define IID_Hidd_BitMap_UAE "hidd.bitmap.uae" + +#include "uaertg.h" + +/* This structure is used as instance data for the bitmap class. */ + +struct bm_data +{ + struct MinNode node; + struct SignalSemaphore bmLock; + OOP_Object *pixfmtobj; /* Cached pixelformat object */ + OOP_Object *gfxhidd; /* Cached driver object */ + ULONG rgbformat; + UBYTE *VideoData; + ULONG memsize; + BOOL invram; + WORD width, height, align; + WORD bytesperpixel; + WORD bytesperline; + UBYTE *palette; + WORD topedge, leftedge; + WORD locked; +}; + +#define LOCK_BITMAP(data) {ObtainSemaphore(&(data)->bmLock);} +#define TRYLOCK_BITMAP(data) (AttemptSemaphore(&(data)->bmLock)) +#define UNLOCK_BITMAP(data) {ReleaseSemaphore(&(data)->bmLock);} + +#endif diff --git a/arch/m68k-amiga/hidd/uaegfx/uaegfx_bitmapclass.c b/arch/m68k-amiga/hidd/uaegfx/uaegfx_bitmapclass.c new file mode 100644 index 0000000000..05753336b3 --- /dev/null +++ b/arch/m68k-amiga/hidd/uaegfx/uaegfx_bitmapclass.c @@ -0,0 +1,1544 @@ +/* + Copyright 1995-2017, The AROS Development Team. All rights reserved. + $Id$ + + Desc: Bitmap class for native Amiga chipset. + Lang: English. + +*/ + +/****************************************************************************************/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEBUG 0 +#define DB2(x) ; +#define DEBUG_TEXT(x) +#define DVRAM(x) ; +#include + +#include LC_LIBDEFS_FILE + +#include "uaegfx_intern.h" +#include "uaegfx_bitmap.h" +#include "uaertg.h" + +/* LOCK_BITMAP_MULTI: + + swap bitmap between RAM <-> VRAM allowed only if this lock is held + + the bitmap being swapped must also get LOCK_BITMAP lock, otherwise + gfx functions (done by other tasks) could render into wrong place while + bitmap is moved around. + +*/ + +static APTR allocrtgvrambitmap(struct uaegfx_staticdata *csd, struct bm_data *bm) +{ + APTR vmem; + SetMemoryMode(csd, RGBFB_CLUT); + vmem = Allocate(csd->vmem, bm->memsize); + SetMemoryMode(csd, bm->rgbformat); + if (vmem) + { + DVRAM(bug("BM %p (%dx%dx%d %d): %p,%d bytes VRAM allocated.\n", bm, bm->width, bm->height, bm->bytesperpixel*8, bm->bytesperline, vmem, bm->memsize)); + } + return vmem; +} + +static void freertgbitmap(struct uaegfx_staticdata *csd, struct bm_data *bm) +{ + DVRAM(bug("BM %p: freeing %p:%d from %s\n", bm, bm->VideoData, bm->memsize, bm->invram ? "VRAM" : "RAM")); + if (bm->invram) + { + SetMemoryMode(csd, RGBFB_CLUT); + Deallocate(csd->vmem, bm->VideoData, bm->memsize); + SetMemoryMode(csd, bm->rgbformat); + csd->vram_used -= bm->memsize; + } + else if (bm->VideoData) + { + FreeMem(bm->VideoData, bm->memsize); + csd->fram_used -= bm->memsize; + } + bm->VideoData = NULL; + bm->invram = FALSE; +} + +static BOOL movebitmaptofram(struct uaegfx_staticdata *csd, struct bm_data *bm) +{ + BOOL ok = FALSE; + APTR vmem; + + /* TRYLOCK here as we are in wrong locking order (could deadlock): + + LOCK_BITMAP_MULTI -> LOCK_HW -> [...] <- UNLOCK_HW <- UNLOCK_BITMAP_MULTI + (Correct locking order is: LOCK_BM_MULTI -> LOCK_BM -> LOCK_HW) + + Alternative would be to always lock all (swappable) bitmaps during bitmap + allocation/freeing routines. */ + + + if (TRYLOCK_BITMAP(bm)) + { + vmem = AllocMem(bm->memsize, MEMF_ANY); + if (vmem) + { + SetMemoryMode(csd, bm->rgbformat); + CopyMemQuick(bm->VideoData, vmem, bm->memsize); + freertgbitmap(csd, bm); + bm->VideoData = vmem; + bm->invram = FALSE; + csd->fram_used += bm->memsize; + ok = TRUE; + } + DVRAM(bug("BM %p: %d x %d moved to RAM %p:%d. VRAM=%d\n", bm, bm->width, bm->height, bm->VideoData, bm->memsize, csd->vram_used)); + + UNLOCK_BITMAP(bm) + } + + return ok; +} + +static BOOL allocrtgbitmap(struct uaegfx_staticdata *csd, struct bm_data *bm, BOOL usevram) +{ + bm->memsize = (bm->bytesperline * bm->height + 7) & ~7; + + if (!(bm->VideoData = allocrtgvrambitmap(csd, bm))) + { + if (usevram && bm->memsize < csd->vram_size) + { + struct bm_data *bmnode; + ForeachNode(&csd->bitmaplist, bmnode) + { + if (bmnode != bm && bmnode->invram && !bmnode->locked) + { + if (movebitmaptofram(csd, bmnode)) + { + if ((bm->VideoData = allocrtgvrambitmap(csd, bm))) + { + csd->vram_used += bm->memsize; + bm->invram = TRUE; + break; + } + } + } + } + } + + if (!bm->VideoData) + { + bm->VideoData = AllocMem(bm->memsize, MEMF_ANY); + if (bm->VideoData) + { + csd->fram_used += bm->memsize; + } + } + } + else + { + csd->vram_used += bm->memsize; + bm->invram = TRUE; + } + DVRAM(bug("BM %p: %p,%d bytes allocated from %s. VRAM=%d\n", bm, bm->VideoData, bm->memsize, bm->invram ? "VRAM" : "RAM", csd->vram_used)); + + //if (bm->VideoData != NULL) + //{ + // int i; + // + // for(i = 0; i < bm->memsize; i++) bm->VideoData[i] = 0xFF; + //} + + return bm->VideoData != NULL; +} + +static BOOL movethisbitmaptovram(struct uaegfx_staticdata *csd, struct bm_data *bm) +{ + APTR vmem = allocrtgvrambitmap(csd, bm); + if (vmem) + { + SetMemoryMode(csd, bm->rgbformat); + CopyMemQuick(bm->VideoData, vmem, bm->memsize); + freertgbitmap(csd, bm); + bm->VideoData = vmem; + bm->invram = TRUE; + csd->vram_used += bm->memsize; + DVRAM(bug("BM %p: %p:%d (%d x %d) moved back to VRAM\n", bm, bm->VideoData, bm->memsize, bm->width, bm->height)); + return TRUE; + } + return FALSE; +} + +static BOOL movebitmaptovram(struct uaegfx_staticdata *csd, struct bm_data *bm) +{ + struct bm_data *bmnode; + + if (bm->invram) + return TRUE; + + DVRAM(bug("BM %p: %p,%d needs to be in VRAM...\n", bm, bm->VideoData, bm->memsize)); + + ForeachNode(&csd->bitmaplist, bmnode) + { + if (bmnode != bm && bmnode->invram && !bmnode->locked) + { + if (movebitmaptofram(csd, bmnode)) + { + if (movethisbitmaptovram(csd, bm)) + { + return TRUE; + } + } + } + } + + DVRAM(bug("-> not enough memory, VRAM=%d\n", csd->vram_used)); + + return FALSE; +} + +#if 0 +static BOOL maybeputinvram(struct uaegfx_staticdata *csd, struct bm_data *bm) +{ + if (bm->invram) + return TRUE; + if (bm->memsize >= csd->vram_size - csd->vram_used) + return FALSE; + return movethisbitmaptovram(csd, bm); +} +#endif + +static void hidescreen(struct uaegfx_staticdata *csd, struct bm_data *bm) +{ + D(bug("Hide %p: (%p:%d)\n", + bm, bm->VideoData, bm->memsize)); + SetInterrupt(csd, FALSE); + SetDisplay(csd, FALSE); + SetSwitch(csd, FALSE); + csd->dmodeid = 0; + bm->locked--; + csd->disp = NULL; +} + +/****************************************************************************************/ + +#define AO(x) (aoHidd_BitMap_ ## x) +#define GOT_BM_ATTR(code) GOT_ATTR(code, aoHidd_BitMap, bitmap) + +/****************************************************************************************/ + +OOP_Object *UAEGFXBitmap__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + BOOL ok = TRUE; + struct bm_data *data; + IPTR width, height, multi; + IPTR displayable; + struct TagItem tags[2]; + + DB2(bug("UAEGFXBitmap__Root__New\n")); + + o =(OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + if (NULL == o) + { + return NULL; + } + + data = OOP_INST_DATA(cl, o); + memset(data, 0, sizeof (*data)); + InitSemaphore(&data->bmLock); + + OOP_GetAttr(o, aHidd_BitMap_Width, &width); + OOP_GetAttr(o, aHidd_BitMap_Height, &height); + OOP_GetAttr(o, aHidd_BitMap_Displayable, &displayable); + OOP_GetAttr(o, aHidd_BitMap_GfxHidd, (APTR)&data->gfxhidd); + OOP_GetAttr(o, aHidd_BitMap_PixFmt, (APTR)&data->pixfmtobj); + OOP_GetAttr(data->pixfmtobj, aHidd_PixFmt_BytesPerPixel, &multi); + + data->rgbformat = getrtgformat(csd, data->pixfmtobj); + data->align = displayable ? 32 : 16; + width = (width + data->align - 1) & ~(data->align - 1); + data->bytesperline = CalculateBytesPerRow(csd, width, data->rgbformat); + data->width = width; + data->height = height; + data->bytesperpixel = multi; + + LOCK_MULTI_BITMAP + + LOCK_HW /* alloc routines call SetMemoryMode */ + WaitBlitter(csd); /* in case bitmaps are swapped between RAM <-> VRAM during allocation */ + allocrtgbitmap(csd, data, TRUE); + UNLOCK_HW + + AddTail(&csd->bitmaplist, (struct Node*)&data->node); + + UNLOCK_MULTI_BITMAP + + tags[0].ti_Tag = aHidd_BitMap_BytesPerRow; + tags[0].ti_Data = data->bytesperline; + tags[1].ti_Tag = TAG_DONE; + OOP_SetAttrs(o, tags); + + DB2(bug("%dx%dx%d %d RGBF=%08x P=%08x\n", width, height, multi, data->bytesperline, data->rgbformat, data->VideoData)); + + if (data->VideoData == NULL) + ok = FALSE; + + if (!ok) { + OOP_MethodID dispose_mid; + dispose_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose); + OOP_CoerceMethod(cl, o, (OOP_Msg)&dispose_mid); + o = NULL; + } + + DB2(bug("ret=%x bm=%p (%p:%d)\n", o, data, data->VideoData, data->memsize)); + + return o; +} + +VOID UAEGFXBitmap__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct bm_data *data; + + data = OOP_INST_DATA(cl, o); + + LOCK_HW + WaitBlitter(csd); + + DB2(bug("UAEGFXBitmap__Root__Dispose %x bm=%x (%p,%d)\n", o, data, data->VideoData, data->memsize)); + if (csd->disp == data) + hidescreen(csd, data); + + UNLOCK_HW + + FreeVec(data->palette); + + LOCK_MULTI_BITMAP + + LOCK_HW /* free functions call SetMemoryMode */ + freertgbitmap(csd, data); + UNLOCK_HW + + Remove((struct Node*)&data->node); + + UNLOCK_MULTI_BITMAP + + OOP_DoSuperMethod(cl, o, msg); +} + +VOID UAEGFXBitmap__Root__Set(OOP_Class *cl, OOP_Object *o, struct pRoot_Set *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct bm_data *data = OOP_INST_DATA(cl, o); + struct TagItem *tag, *tstate; + ULONG idx; + BOOL moved = FALSE; + + DB2(bug("UAEGFXBitmap__Root__Set %p (%p:%d)\n", data, data->VideoData, data->memsize)); + tstate = msg->attrList; + while((tag = NextTagItem(&tstate))) + { + DB2(bug("%d/%d\n", tag->ti_Tag, tag->ti_Data)); + if(IS_BITMAP_ATTR(tag->ti_Tag, idx)) + { + DB2(bug("->%d\n", idx)); + switch(idx) + { + case aoHidd_BitMap_Visible: + LOCK_MULTI_BITMAP + LOCK_BITMAP(data) + LOCK_HW + if (tag->ti_Data) { + OOP_Object *gfxhidd, *sync, *pf; + IPTR modeid = vHidd_ModeID_Invalid; + IPTR dwidth, dheight, depth, width, height; + struct ModeInfo *modeinfo; + + width = data->width; + height = data->height; + OOP_GetAttr(o, aHidd_BitMap_ModeID , &modeid); + OOP_GetAttr(o, aHidd_BitMap_GfxHidd, (IPTR *)&gfxhidd); + HIDD_Gfx_GetMode(gfxhidd, modeid, &sync, &pf); + OOP_GetAttr(sync, aHidd_Sync_HDisp, &dwidth); + OOP_GetAttr(sync, aHidd_Sync_VDisp, &dheight); + OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth); + data->rgbformat = getrtgformat(csd, pf); + modeinfo = getrtgmodeinfo(csd, sync, pf, csd->fakemodeinfo); + csd->modeinfo = modeinfo; + csd->rgbformat = data->rgbformat; + pw(csd->bitmapextra + PSSO_BitMapExtra_Width, width); + pw(csd->bitmapextra + PSSO_BitMapExtra_Height, height); + D(bug("Show %p: (%p:%d) %dx%dx%d (%dx%d) BF=%08x\n", + data, data->VideoData, data->memsize, + dwidth, dheight, depth, width, height, data->rgbformat)); + + if (!data->invram) + { + WaitBlitter(csd); /* in case other bitmaps are swapped from VRAM to RAM */ + if (!movebitmaptovram(csd, data)) + { + struct bm_data *bmnode; + + /* Second try. Now lock all bitmaps first. UNLOCK_HW first, to ensure + correct locking order: multibm -> bm -> hw */ + + UNLOCK_HW + + ForeachNode(&csd->bitmaplist, bmnode) + { + if (bmnode != data) LOCK_BITMAP(bmnode) + } + + LOCK_HW + WaitBlitter(csd); /* in case other bitmaps are swapped from VRAM to RAM */ + movebitmaptovram(csd, data); /* shouldn't fail this time. If it does we are screwed ... */ + UNLOCK_HW + + ForeachNode(&csd->bitmaplist, bmnode) + { + if (bmnode != data) UNLOCK_BITMAP(bmnode) + } + + LOCK_HW + } + } + + csd->dwidth = dwidth; + csd->dheight = dheight; + csd->dmodeid = modeid; + + if (csd->hardwaresprite && depth <= 8) { + UWORD i; + UBYTE *clut = csd->boardinfo + PSSO_BoardInfo_CLUT; + for (i = csd->spritecolors + 1; i < csd->spritecolors + 4; i++) + SetSpriteColor(csd, i - (csd->spritecolors + 1), clut[i * 3 + 0], clut[i * 3 + 1], clut[i * 3 + 2]); + } + SetInterrupt(csd, FALSE); + SetColorArray(csd, 0, 256); + SetDisplay(csd, FALSE); + SetGC(csd, modeinfo, 0); + SetClock(csd); + SetDAC(csd); + SetPanning(csd, data->VideoData, width, 0, 0); + SetDisplay(csd, TRUE); + SetSwitch(csd, TRUE); + SetInterrupt(csd, TRUE); + csd->disp = data; + csd->disp->locked++; + } else { + hidescreen(csd, data); + } + UNLOCK_HW + UNLOCK_BITMAP(data) + UNLOCK_MULTI_BITMAP + + break; + case aoHidd_BitMap_LeftEdge: + if (data->leftedge != tag->ti_Data) { + data->leftedge = tag->ti_Data; + moved = TRUE; + } + break; + case aoHidd_BitMap_TopEdge: + if (data->topedge != tag->ti_Data) { + data->topedge = tag->ti_Data; + moved = TRUE; + } + break; + } + } + } + DB2(bug("UAEGFXBitmap__Root__Set Exit\n")); + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); +#if 0 + if (moved && csd->disp == data) + setscroll(csd, data); +#else + (void)moved; +#endif +} + +VOID UAEGFXBitmap__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct bm_data *data = OOP_INST_DATA(cl, o); + ULONG idx; + + //DB2(bug("UAEGFXBitmap__Root__Get\n")); + if (IS_BITMAP_ATTR(msg->attrID, idx)) { + //DB2(bug("=%d\n", idx)); + switch (idx) { + case aoHidd_BitMap_LeftEdge: + *msg->storage = 0;//data->leftedge; + return; + case aoHidd_BitMap_TopEdge: + *msg->storage = 0;//data->topedge; + return; + case aoHidd_BitMap_Visible: + *msg->storage = csd->disp == data; + return; + case aoHidd_BitMap_Align: + *msg->storage = data->align; + return; + case aoHidd_BitMap_BytesPerRow: + *msg->storage = data->bytesperline; + return; + case aoHidd_BitMap_IsLinearMem: + *msg->storage = TRUE; + return; + } + } + //DB2(bug("UAEGFXBitmap__Root__Get Exit\n")); + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); +} + +/****************************************************************************************/ + +static int UAEGFXBitmap_Init(LIBBASETYPEPTR LIBBASE) +{ + D(bug("UAEGFXBitmap_Init\n")); + return TRUE; //return OOP_ObtainAttrBases(attrbases); +} + +/****************************************************************************************/ + +static int UAEGFXBitmap_Expunge(LIBBASETYPEPTR LIBBASE) +{ + D(bug("UAEGFXBitmap_Expunge\n")); + //OOP_ReleaseAttrBases(attrbases); + return TRUE; +} + +/****************************************************************************************/ + +ADD2INITLIB(UAEGFXBitmap_Init, 0); +ADD2EXPUNGELIB(UAEGFXBitmap_Expunge, 0); + +BOOL UAEGFXBitmap__Hidd_BitMap__ObtainDirectAccess(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_ObtainDirectAccess *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct bm_data *data = OOP_INST_DATA(cl, o); + + LOCK_BITMAP(data) + +#if 0 + if (!data->invram) { + if (!movebitmaptovram(csd, data)) + return FALSE; + } +#endif + + *msg->addressReturn = data->VideoData; + *msg->widthReturn = data->width; + *msg->heightReturn = data->height; + /* undocumented, just a guess.. */ + *msg->bankSizeReturn = *msg->memSizeReturn = data->bytesperline * data->height; + data->locked++; + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + return TRUE; +} + +VOID UAEGFXBitmap__Hidd_BitMap__ReleaseDirectAccess(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_ReleaseDirectAccess *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct bm_data *data = OOP_INST_DATA(cl, o); + data->locked--; + + UNLOCK_BITMAP(data) +} + +BOOL UAEGFXBitmap__Hidd_BitMap__SetColors(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_SetColors *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + WORD i, j; + UBYTE *clut; + + if (!OOP_DoSuperMethod(cl, o, (OOP_Msg)msg)) + return FALSE; + + LOCK_HW + + WaitBlitter(csd); + clut = csd->boardinfo + PSSO_BoardInfo_CLUT; + for (i = msg->firstColor, j = 0; j < msg->numColors; i++, j++) { + clut[i * 3 + 0] = msg->colors[j].red >> 8; + clut[i * 3 + 1] = msg->colors[j].green >> 8; + clut[i * 3 + 2] = msg->colors[j].blue >> 8; + //bug("UAESET color %d %02x%02x%02x\n", i, msg->colors[j].red >> 8, msg->colors[j].green >> 8, msg->colors[j].blue >> 8); + } + SetColorArray(csd, msg->firstColor, msg->numColors); + + UNLOCK_HW + + return TRUE; +} + +VOID UAEGFXBitmap__Hidd_BitMap__PutPixel(OOP_Class *cl, OOP_Object *o, + struct pHidd_BitMap_PutPixel *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct bm_data *data = OOP_INST_DATA(cl, o); + ULONG offset; + HIDDT_Pixel pixel = msg->pixel; + UBYTE *mem; + + LOCK_BITMAP(data) + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + offset = (msg->x * data->bytesperpixel) + (msg->y * data->bytesperline); + mem = data->VideoData + offset; + + switch(data->bytesperpixel) + { + case 1: + *(UBYTE *)mem = pixel; + break; + + case 2: + *(UWORD *)mem = pixel; + break; + + case 3: + *(UBYTE *)(mem) = pixel >> 16; + *(UBYTE *)(mem + 1) = pixel >> 8; + *(UBYTE *)(mem + 2) = pixel; + break; + + case 4: + *(ULONG *)mem = pixel; + break; + } + + UNLOCK_BITMAP(data) + + return; +} + +/****************************************************************************************/ + +ULONG UAEGFXBitmap__Hidd_BitMap__GetPixel(OOP_Class *cl, OOP_Object *o, + struct pHidd_BitMap_GetPixel *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct bm_data *data = OOP_INST_DATA(cl, o); + HIDDT_Pixel pixel = 0; + ULONG offset; + UBYTE *mem; + + LOCK_BITMAP(data) + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + offset = (msg->x * data->bytesperpixel) +(msg->y * data->bytesperline); + mem = data->VideoData + offset; + + switch(data->bytesperpixel) + { + case 1: + pixel = *(UBYTE *)mem; + break; + + case 2: + pixel = *(UWORD *)mem; + break; + + case 3: + pixel = (mem[0] << 16) | (mem[1] << 8) | mem[2]; + break; + + case 4: + pixel = *(ULONG *)mem; + break; + + } + + UNLOCK_BITMAP(data) + + return pixel; +} + +/****************************************************************************************/ + +VOID UAEGFXBitmap__Hidd_BitMap__DrawLine(OOP_Class *cl, OOP_Object *o, + struct pHidd_BitMap_DrawLine *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); +} + +/****************************************************************************************/ + +VOID UAEGFXBitmap__Hidd_BitMap__GetImage(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_GetImage *msg) +{ + struct bm_data *data = OOP_INST_DATA(cl, o); + struct uaegfx_staticdata *csd = CSD(cl); + + LOCK_BITMAP(data) + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + switch(msg->pixFmt) + { + case vHidd_StdPixFmt_Native: + switch(data->bytesperpixel) + { + case 1: + HIDD_BM_CopyMemBox8(o, + data->VideoData, + msg->x, + msg->y, + msg->pixels, + 0, + 0, + msg->width, + msg->height, + data->bytesperline, + msg->modulo); + break; + + case 2: + HIDD_BM_CopyMemBox16(o, + data->VideoData, + msg->x, + msg->y, + msg->pixels, + 0, + 0, + msg->width, + msg->height, + data->bytesperline, + msg->modulo); + break; + + case 3: + HIDD_BM_CopyMemBox24(o, + data->VideoData, + msg->x, + msg->y, + msg->pixels, + 0, + 0, + msg->width, + msg->height, + data->bytesperline, + msg->modulo); + break; + + case 4: + HIDD_BM_CopyMemBox32(o, + data->VideoData, + msg->x, + msg->y, + msg->pixels, + 0, + 0, + msg->width, + msg->height, + data->bytesperline, + msg->modulo); + break; + + } /* switch(data->bytesperpix) */ + break; + + case vHidd_StdPixFmt_Native32: + switch(data->bytesperpixel) + { + case 1: + HIDD_BM_GetMem32Image8(o, + data->VideoData, + msg->x, + msg->y, + msg->pixels, + msg->width, + msg->height, + data->bytesperline, + msg->modulo); + break; + + case 2: + HIDD_BM_GetMem32Image16(o, + data->VideoData, + msg->x, + msg->y, + msg->pixels, + msg->width, + msg->height, + data->bytesperline, + msg->modulo); + break; + + case 3: + HIDD_BM_GetMem32Image24(o, + data->VideoData, + msg->x, + msg->y, + msg->pixels, + msg->width, + msg->height, + data->bytesperline, + msg->modulo); + break; + + case 4: + HIDD_BM_CopyMemBox32(o, + data->VideoData, + msg->x, + msg->y, + msg->pixels, + 0, + 0, + msg->width, + msg->height, + data->bytesperline, + msg->modulo); + break; + + } /* switch(data->bytesperpix) */ + break; + + default: + { + APTR pixels = msg->pixels; + APTR srcPixels = data->VideoData + msg->y * data->bytesperline + msg->x * data->bytesperpixel; + OOP_Object *dstpf; + + dstpf = HIDD_Gfx_GetPixFmt(data->gfxhidd, msg->pixFmt); + + HIDD_BM_ConvertPixels(o, &srcPixels, (HIDDT_PixelFormat *)data->pixfmtobj, data->bytesperline, + &pixels, (HIDDT_PixelFormat *)dstpf, msg->modulo, + msg->width, msg->height, NULL); + } + break; + + } /* switch(msg->pixFmt) */ + + UNLOCK_BITMAP(data) +} + +/****************************************************************************************/ + +VOID UAEGFXBitmap__Hidd_BitMap__PutImage(OOP_Class *cl, OOP_Object *o, + struct pHidd_BitMap_PutImage *msg) +{ + struct bm_data *data = OOP_INST_DATA(cl, o); + struct uaegfx_staticdata *csd = CSD(cl); + + LOCK_BITMAP(data) + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + switch(msg->pixFmt) + { + case vHidd_StdPixFmt_Native: + switch(data->bytesperpixel) + { + case 1: + HIDD_BM_CopyMemBox8(o, + msg->pixels, + 0, + 0, + data->VideoData, + msg->x, + msg->y, + msg->width, + msg->height, + msg->modulo, + data->bytesperline); + break; + + case 2: + HIDD_BM_CopyMemBox16(o, + msg->pixels, + 0, + 0, + data->VideoData, + msg->x, + msg->y, + msg->width, + msg->height, + msg->modulo, + data->bytesperline); + break; + + case 3: + HIDD_BM_CopyMemBox24(o, + msg->pixels, + 0, + 0, + data->VideoData, + msg->x, + msg->y, + msg->width, + msg->height, + msg->modulo, + data->bytesperline); + break; + + case 4: + HIDD_BM_CopyMemBox32(o, + msg->pixels, + 0, + 0, + data->VideoData, + msg->x, + msg->y, + msg->width, + msg->height, + msg->modulo, + data->bytesperline); + break; + + } /* switch(data->bytesperpix) */ + break; + + case vHidd_StdPixFmt_Native32: + switch(data->bytesperpixel) + { + case 1: + HIDD_BM_PutMem32Image8(o, + msg->pixels, + data->VideoData, + msg->x, + msg->y, + msg->width, + msg->height, + msg->modulo, + data->bytesperline); + break; + + case 2: + HIDD_BM_PutMem32Image16(o, + msg->pixels, + data->VideoData, + msg->x, + msg->y, + msg->width, + msg->height, + msg->modulo, + data->bytesperline); + break; + + case 3: + HIDD_BM_PutMem32Image24(o, + msg->pixels, + data->VideoData, + msg->x, + msg->y, + msg->width, + msg->height, + msg->modulo, + data->bytesperline); + break; + + case 4: + HIDD_BM_CopyMemBox32(o, + msg->pixels, + 0, + 0, + data->VideoData, + msg->x, + msg->y, + msg->width, + msg->height, + msg->modulo, + data->bytesperline); + break; + + } /* switch(data->bytesperpix) */ + break; + + default: + { + APTR pixels = msg->pixels; + APTR dstBuf = data->VideoData + msg->y * data->bytesperline + msg->x * data->bytesperpixel; + OOP_Object *srcpf; + + srcpf = HIDD_Gfx_GetPixFmt(data->gfxhidd, msg->pixFmt); + + HIDD_BM_ConvertPixels(o, &pixels, (HIDDT_PixelFormat *)srcpf, msg->modulo, + &dstBuf, (HIDDT_PixelFormat *)data->pixfmtobj, data->bytesperline, + msg->width, msg->height, NULL); + } + break; + + } /* switch(msg->pixFmt) */ + + UNLOCK_BITMAP(data) +} + +/****************************************************************************************/ + +VOID UAEGFXBitmap__Hidd_BitMap__PutImageLUT(OOP_Class *cl, OOP_Object *o, + struct pHidd_BitMap_PutImageLUT *msg) +{ + struct bm_data *data = OOP_INST_DATA(cl, o); + struct uaegfx_staticdata *csd = CSD(cl); + + LOCK_BITMAP(data) + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + switch(data->bytesperpixel) + { + case 2: + HIDD_BM_CopyLUTMemBox16(o, + msg->pixels, + 0, + 0, + data->VideoData, + msg->x, + msg->y, + msg->width, + msg->height, + msg->modulo, + data->bytesperline, + msg->pixlut); + break; + + case 3: + HIDD_BM_CopyLUTMemBox24(o, + msg->pixels, + 0, + 0, + data->VideoData, + msg->x, + msg->y, + msg->width, + msg->height, + msg->modulo, + data->bytesperline, + msg->pixlut); + break; + + case 4: + HIDD_BM_CopyLUTMemBox32(o, + msg->pixels, + 0, + 0, + data->VideoData, + msg->x, + msg->y, + msg->width, + msg->height, + msg->modulo, + data->bytesperline, + msg->pixlut); + break; + + default: + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + break; + + } /* switch(data->bytesperpix) */ + + UNLOCK_BITMAP(data) +} + +/****************************************************************************************/ + +VOID UAEGFXBitmap__Hidd_BitMap__GetImageLUT(OOP_Class *cl, OOP_Object *o, + struct pHidd_BitMap_GetImageLUT *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); +} + +/****************************************************************************************/ + +VOID UAEGFXBitmap__Hidd_BitMap__FillRect(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_DrawRect *msg) +{ + HIDDT_Pixel fg = GC_FG(msg->gc); + HIDDT_DrawMode mode = GC_DRMD(msg->gc); + struct uaegfx_staticdata *csd = CSD(cl); + struct bm_data *data = OOP_INST_DATA(cl, o); + struct RenderInfo ri; + BOOL v = FALSE; + + LOCK_BITMAP(data) + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW +#if 0 + maybeputinvram(csd, data); +#endif + + if (data->invram) { + makerenderinfo(csd, &ri, data); + + LOCK_HW + + if (mode == vHidd_GC_DrawMode_Clear || mode == vHidd_GC_DrawMode_Set) { + ULONG pen = mode == vHidd_GC_DrawMode_Clear ? 0x00000000 : 0xffffffff; + v = FillRect(csd, &ri, msg->minX, msg->minY, msg->maxX - msg->minX + 1, msg->maxY - msg->minY + 1, pen, 0xff, data->rgbformat); + } else if (mode == vHidd_GC_DrawMode_Copy) { + v = FillRect(csd, &ri, msg->minX, msg->minY, msg->maxX - msg->minX + 1, msg->maxY - msg->minY + 1, fg, 0xff, data->rgbformat); + } else if (mode == vHidd_GC_DrawMode_Invert) { + v = InvertRect(csd, &ri, msg->minX, msg->minY, msg->maxX - msg->minX + 1, msg->maxY - msg->minY + 1, 0xff, data->rgbformat); + } + + UNLOCK_HW + } + + if (!v) switch(mode) + { + case vHidd_GC_DrawMode_Copy: + switch(data->bytesperpixel) + { + case 1: + HIDD_BM_FillMemRect8(o, + data->VideoData, + msg->minX, + msg->minY, + msg->maxX, + msg->maxY, + data->bytesperline, + fg); + break; + + case 2: + HIDD_BM_FillMemRect16(o, + data->VideoData, + msg->minX, + msg->minY, + msg->maxX, + msg->maxY, + data->bytesperline, + fg); + break; + + case 3: + HIDD_BM_FillMemRect24(o, + data->VideoData, + msg->minX, + msg->minY, + msg->maxX, + msg->maxY, + data->bytesperline, + fg); + break; + + case 4: + HIDD_BM_FillMemRect32(o, + data->VideoData, + msg->minX, + msg->minY, + msg->maxX, + msg->maxY, + data->bytesperline, + fg); + break; + + } + break; + + case vHidd_GC_DrawMode_Invert: + HIDD_BM_InvertMemRect(o, + data->VideoData, + msg->minX * data->bytesperpixel, + msg->minY, + msg->maxX * data->bytesperpixel + data->bytesperpixel - 1, + msg->maxY, + data->bytesperline); + break; + + default: + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + break; + + } /* switch(mode) */ + + UNLOCK_BITMAP(data) + +} + +/****************************************************************************************/ + +VOID UAEGFXBitmap__Hidd_BitMap__PutPattern(OOP_Class *cl, OOP_Object *o, + struct pHidd_BitMap_PutPattern *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct bm_data *data = OOP_INST_DATA(cl, o); + HIDDT_Pixel fg = GC_FG(msg->gc); + HIDDT_Pixel bg = GC_BG(msg->gc); + struct Pattern pat; + struct RenderInfo ri; + UBYTE drawmode; + BOOL v = FALSE; + + LOCK_BITMAP(data) + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + DB2(bug("blitpattern(%d,%d)(%d,%d)(%x,%d,%d,%d,%d,%d)\n", + msg->x, msg->y, msg->width, msg->height, + msg->pattern, msg->patternsrcx, msg->patternsrcy, fg, bg, msg->patternheight)); + + if ((msg->mask == NULL) && (msg->patterndepth == 1)) + { + switch (msg->patternheight) + { + case 1: + pat.Size = 0; + break; + case 2: + pat.Size = 1; + break; + case 4: + pat.Size = 2; + break; + case 8: + pat.Size = 3; + break; + case 16: + pat.Size = 4; + break; + case 32: + pat.Size = 5; + break; + case 64: + pat.Size = 6; + break; + case 128: + pat.Size = 7; + break; + case 256: + pat.Size = 8; + break; + default: + pat.Size = 0xff; + } + + if (pat.Size <= 8) + { +#if 0 + maybeputinvram(csd, data); +#endif + if (data->invram) + { + makerenderinfo(csd, &ri, data); + if (GC_COLEXP(msg->gc) == vHidd_GC_ColExp_Transparent) + drawmode = JAM1; + else if (GC_DRMD(msg->gc) == vHidd_GC_DrawMode_Invert) + drawmode = COMPLEMENT; + else + drawmode = JAM2; + if (msg->invertpattern) + drawmode |= INVERSVID; + + pat.Memory = msg->pattern; + pat.XOffset = msg->patternsrcx; + pat.YOffset = msg->patternsrcy; + pat.FgPen = fg; + pat.BgPen = bg; + pat.DrawMode = drawmode; + + LOCK_HW + + v = BlitPattern(csd, &ri, &pat, msg->x, msg->y, msg->width, msg->height, 0xff, data->rgbformat); + + UNLOCK_HW + } + } + } + + if (!v) switch(data->bytesperpixel) + { + case 1: + HIDD_BM_PutMemPattern8(o, + msg->gc, + msg->pattern, + msg->patternsrcx, + msg->patternsrcy, + msg->patternheight, + msg->patterndepth, + msg->patternlut, + msg->invertpattern, + msg->mask, + msg->maskmodulo, + msg->masksrcx, + data->VideoData, + data->bytesperline, + msg->x, + msg->y, + msg->width, + msg->height); + break; + + case 2: + HIDD_BM_PutMemPattern16(o, + msg->gc, + msg->pattern, + msg->patternsrcx, + msg->patternsrcy, + msg->patternheight, + msg->patterndepth, + msg->patternlut, + msg->invertpattern, + msg->mask, + msg->maskmodulo, + msg->masksrcx, + data->VideoData, + data->bytesperline, + msg->x, + msg->y, + msg->width, + msg->height); + break; + + case 3: + HIDD_BM_PutMemPattern24(o, + msg->gc, + msg->pattern, + msg->patternsrcx, + msg->patternsrcy, + msg->patternheight, + msg->patterndepth, + msg->patternlut, + msg->invertpattern, + msg->mask, + msg->maskmodulo, + msg->masksrcx, + data->VideoData, + data->bytesperline, + msg->x, + msg->y, + msg->width, + msg->height); + break; + + case 4: + HIDD_BM_PutMemPattern32(o, + msg->gc, + msg->pattern, + msg->patternsrcx, + msg->patternsrcy, + msg->patternheight, + msg->patterndepth, + msg->patternlut, + msg->invertpattern, + msg->mask, + msg->maskmodulo, + msg->masksrcx, + data->VideoData, + data->bytesperline, + msg->x, + msg->y, + msg->width, + msg->height); + break; + + default: + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + break; + + } /* switch(data->bytesperpixel) */ + + UNLOCK_BITMAP(data) + +} + +/****************************************************************************************/ + +VOID UAEGFXBitmap__Hidd_BitMap__PutTemplate(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_PutTemplate *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct bm_data *data = OOP_INST_DATA(cl, o); + HIDDT_Pixel fg = GC_FG(msg->gc); + HIDDT_Pixel bg = GC_BG(msg->gc); + struct Template tmpl; + struct RenderInfo ri; + UBYTE drawmode; + BOOL v = FALSE; + + LOCK_BITMAP(data) + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + +#if 0 + maybeputinvram(csd, data); +#endif + + if (data->invram) { + makerenderinfo(csd, &ri, data); + if (GC_COLEXP(msg->gc) == vHidd_GC_ColExp_Transparent) + drawmode = JAM1; + else if (GC_DRMD(msg->gc) == vHidd_GC_DrawMode_Invert) + drawmode = COMPLEMENT; + else + drawmode = JAM2; + if (msg->inverttemplate) + drawmode |= INVERSVID; + + /* tmpl.XOffset has only UBYTE size so we must fix params up [1] [2] */ + + tmpl.Memory = msg->masktemplate + ((msg->srcx / 8) & ~1); /* [1] */ + tmpl.BytesPerRow = msg->modulo; + tmpl.XOffset = msg->srcx & 0XF; /* [2] */ + tmpl.DrawMode = drawmode; + tmpl.FgPen = fg; + tmpl.BgPen = bg; + + LOCK_HW + v = BlitTemplate(csd, &ri, &tmpl, msg->x, msg->y, msg->width, msg->height, 0xff, data->rgbformat); + UNLOCK_HW + } + + if (!v) switch(data->bytesperpixel) + { + case 1: + HIDD_BM_PutMemTemplate8(o, + msg->gc, + msg->masktemplate, + msg->modulo, + msg->srcx, + data->VideoData, + data->bytesperline, + msg->x, + msg->y, + msg->width, + msg->height, + msg->inverttemplate); + break; + + case 2: + HIDD_BM_PutMemTemplate16(o, + msg->gc, + msg->masktemplate, + msg->modulo, + msg->srcx, + data->VideoData, + data->bytesperline, + msg->x, + msg->y, + msg->width, + msg->height, + msg->inverttemplate); + break; + + case 3: + HIDD_BM_PutMemTemplate24(o, + msg->gc, + msg->masktemplate, + msg->modulo, + msg->srcx, + data->VideoData, + data->bytesperline, + msg->x, + msg->y, + msg->width, + msg->height, + msg->inverttemplate); + break; + + case 4: + HIDD_BM_PutMemTemplate32(o, + msg->gc, + msg->masktemplate, + msg->modulo, + msg->srcx, + data->VideoData, + data->bytesperline, + msg->x, + msg->y, + msg->width, + msg->height, + msg->inverttemplate); + break; + + default: + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + break; + + } /* switch(data->bytesperpixel) */ + + UNLOCK_BITMAP(data) + +} + + +/****************************************************************************************/ + +VOID UAEGFXBitmap__Hidd_BitMap__UpdateRect(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_UpdateRect *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); +} + +/****************************************************************************************/ + +BOOL UAEGFXBitmap__Hidd_PlanarBM__SetBitMap(OOP_Class *cl, OOP_Object *o, + struct pHidd_PlanarBM_SetBitMap *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + return OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); +} + +/****************************************************************************************/ + +BOOL UAEGFXBitmap__Hidd_PlanarBM__GetBitMap(OOP_Class *cl, OOP_Object *o, + struct pHidd_PlanarBM_GetBitMap *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + return OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); +} diff --git a/arch/m68k-amiga/hidd/uaegfx/uaegfx_hidd.h b/arch/m68k-amiga/hidd/uaegfx/uaegfx_hidd.h new file mode 100644 index 0000000000..05b12edf20 --- /dev/null +++ b/arch/m68k-amiga/hidd/uaegfx/uaegfx_hidd.h @@ -0,0 +1,3 @@ + +#define UAEGFX_LIBNAME "uaegfx.hidd" +#define CLID_Hidd_Gfx_UAE "hidd.gfx.uae" diff --git a/arch/m68k-amiga/hidd/uaegfx/uaegfx_hiddclass.c b/arch/m68k-amiga/hidd/uaegfx/uaegfx_hiddclass.c new file mode 100644 index 0000000000..4d67408435 --- /dev/null +++ b/arch/m68k-amiga/hidd/uaegfx/uaegfx_hiddclass.c @@ -0,0 +1,1299 @@ +/* + Copyright 1995-2017, The AROS Development Team. All rights reserved. + $Id$ + + Desc: UAE Gfx Hidd + Lang: English. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include LC_LIBDEFS_FILE + +#include "uaegfx_intern.h" +#include "uaegfx_bitmap.h" +#include "uaertg.h" + +#define SDEBUG 0 +#define DEBUG 0 +#define DRTG(x) x; +#include + +#define SIZE_RESLIST 5 +#define SIZE_PFLIST 19 +#define SIZE_MODELIST (5 + RGBFB_MaxFormats) + +HIDDT_ModeID *UAEGFXCl__Hidd_Gfx__QueryModeIDs(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_QueryModeIDs *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct RTGMode *node; + struct TagItem *tag, *tstate; + ULONG minwidth = 0, maxwidth = 0xFFFFFFFF; + ULONG minheight = 0, maxheight = 0xFFFFFFFF; + OOP_Object **pf = NULL; + HIDDT_ModeID *modeids; + WORD cnt; + + if (csd->superforward) + return (HIDDT_ModeID*)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + + for (tstate = msg->queryTags; (tag = NextTagItem(&tstate)); ) + { + switch (tag->ti_Tag) + { + case tHidd_GfxMode_MinWidth: + minwidth = (ULONG)tag->ti_Tag; + break; + + case tHidd_GfxMode_MaxWidth: + maxwidth = (ULONG)tag->ti_Tag; + break; + + case tHidd_GfxMode_MinHeight: + minheight = (ULONG)tag->ti_Tag; + break; + + case tHidd_GfxMode_MaxHeight: + maxheight = (ULONG)tag->ti_Tag; + break; + + case tHidd_GfxMode_PixFmts: + pf = (OOP_Object**)tag->ti_Tag; + break; + + } + } + DB2(bug("QueryModeIDs (%dx%d)-(%dx%d) %p\n", minwidth, minheight, maxwidth, maxheight, pf)); + cnt = 0; + ForeachNode(&csd->rtglist, node) { + if (node->width >= minwidth && node->width <= maxwidth && node->height >= minheight && node->height <= maxheight) { + OOP_Object **pfp = NULL; + if (pf) { + pfp = pf; + while (*pfp) { + if (*pfp == node->pf) { + pfp = NULL; + break; + } + pfp++; + } + } + if (!pfp) + cnt++; + } + } + modeids = AllocVec((cnt + 1) * sizeof(HIDDT_ModeID), MEMF_PUBLIC); + if (!modeids) + return NULL; + cnt = 0; + ForeachNode(&csd->rtglist, node) { + if (node->width >= minwidth && node->width <= maxwidth && node->height >= minheight && node->height <= maxheight) { + OOP_Object **pfp = NULL; + if (pf) { + pfp = pf; + while (*pfp) { + if (*pfp == node->pf) { + pfp = NULL; + break; + } + pfp++; + } + } + if (!pfp) { + DB2(bug("%d: %08x\n", cnt, node->modeid)); + modeids[cnt++] = node->modeid; + } + } + } + modeids[cnt] = vHidd_ModeID_Invalid; + return modeids; +} + +VOID UAEGFXCl__Hidd_Gfx__ReleaseModeIDs(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_ReleaseModeIDs *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + if (csd->superforward) + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + else + FreeVec(msg->modeIDs); +} + +HIDDT_ModeID UAEGFXCl__Hidd_Gfx__NextModeID(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_NextModeID *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct RTGMode *node = NULL; + HIDDT_ModeID mid = vHidd_ModeID_Invalid; + + DB2(bug("NextModeID %08x\n", msg->modeID)); + if (msg->modeID != vHidd_ModeID_Invalid) { + ForeachNode(&csd->rtglist, node) { + if (node->modeid == msg->modeID) { + node = (struct RTGMode*)node->node.ln_Succ; + break; + } + } + } + if (!node) + node = (struct RTGMode*)csd->rtglist.lh_Head; + if (node->node.ln_Succ) { + mid = node->modeid; + *msg->syncPtr = node->sync; + *msg->pixFmtPtr = node->pf; + } + DB2(bug("=%08x %p %p\n", mid, *msg->syncPtr, *msg->pixFmtPtr)); + return mid; +} + +BOOL UAEGFXCl__Hidd_Gfx__GetMode(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_GetMode *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct RTGMode *node; + + if (csd->superforward) + return (BOOL)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + + DB2(bug("GetMode %08x\n", msg->modeID)); + ForeachNode(&csd->rtglist, node) { + if (node->modeid == msg->modeID) { + *msg->syncPtr = node->sync; + *msg->pixFmtPtr = node->pf; + DB2(bug("= %p %p\n", node->sync, node->pf)); + return TRUE; + } + } + DB2(bug("= FAIL\n")); + return FALSE; +} + +struct RTGFormat +{ + UWORD rgbformat; + ULONG rm, gm, bm, am; + UWORD rs, gs, bs, as; + BOOL endianswap; +}; + +static const struct RTGFormat formats[] = +{ + { RGBFB_CLUT, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000, 8, 16, 24, 0, FALSE }, + + { RGBFB_B8G8R8A8, 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff, 16, 8, 0, 24, FALSE }, + { RGBFB_R8G8B8A8, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff, 0, 8, 16, 24, FALSE }, + { RGBFB_A8B8G8R8, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, 24, 16, 8, 0, FALSE }, + { RGBFB_A8R8G8B8, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000, 8, 16, 24, 0, FALSE }, + + { RGBFB_B8G8R8, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000, 24, 16, 8, 0, FALSE }, + { RGBFB_R8G8B8, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000, 8, 16, 24, 0, FALSE }, + + { RGBFB_R5G5B5, 0x00007c00, 0x000003e0, 0x0000001f, 0x00000000, 17, 22, 27, 0, FALSE }, + { RGBFB_R5G6B5, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000, 16, 21, 27, 0, FALSE }, + + { RGBFB_R5G5B5PC, 0x00007c00, 0x000003e0, 0x0000001f, 0x00000000, 17, 22, 27, 0, TRUE }, + { RGBFB_R5G6B5PC, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000, 16, 21, 27, 0, TRUE }, +/* + { RGBFB_B5G5R5PC, 0x0000003e, 0x000007c0, 0x0000f800, 0x00000000, 26, 21, 16, 0, TRUE }, + { RGBFB_B5G6R5PC, 0x0000001f, 0x000007e0, 0x0000f800, 0x00000000, 27, 21, 16, 0, TRUE }, +*/ + { 0 } +}; + +static const UBYTE rgbtypelist[] = { + RGBFB_CLUT, + + RGBFB_R5G6B5PC, + RGBFB_R5G5B5PC, + RGBFB_B5G6R5PC, + RGBFB_B5G5R5PC, + RGBFB_R5G6B5, + RGBFB_R5G5B5, + + RGBFB_B8G8R8, + RGBFB_R8G8B8, + + RGBFB_B8G8R8A8, + RGBFB_A8B8G8R8, + RGBFB_A8R8G8B8, + RGBFB_R8G8B8A8, + 0 +}; + +OOP_Object *UAEGFXCl__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct LibResolution *r; + WORD rescnt, i, j, k, l; + struct TagItem *reslist, *restags, *pflist, *modetags; + struct pRoot_New mymsg; + struct TagItem mytags[] = { + { aHidd_Gfx_ModeTags, (IPTR)NULL }, + { aHidd_Name , (IPTR)"uaegfx.hidd" }, + { aHidd_HardwareName , (IPTR)"UAE Native Display Adaptor" }, + { aHidd_ProducerName , (IPTR)"UAE" }, + { TAG_MORE, 0UL } + }; + UWORD supportedformats, gotmodes; + + if (csd->initialized) + return NULL; + + NEWLIST(&csd->rtglist); + NEWLIST(&csd->bitmaplist); + InitSemaphore(&csd->HWLock); + InitSemaphore(&csd->MultiBMLock); + + supportedformats = gw(csd->boardinfo + PSSO_BoardInfo_RGBFormats); + //kprintf("====== SUPPORTED FORMATS: 0x%x\n", supportedformats); + + rescnt = 0; + ForeachNode(csd->boardinfo + PSSO_BoardInfo_ResolutionsList, r) { + rescnt++; + } + D(bug("UAEGFX: resolutions: %d, supportmask: %x\n", rescnt, supportedformats)); + + reslist = AllocVec(rescnt * SIZE_RESLIST * sizeof(struct TagItem), MEMF_PUBLIC | MEMF_CLEAR); + restags = AllocVec((rescnt + 1) * sizeof(struct TagItem), MEMF_PUBLIC | MEMF_CLEAR); + pflist = AllocVec(RGBFB_MaxFormats * SIZE_PFLIST * sizeof(struct TagItem), MEMF_PUBLIC | MEMF_CLEAR); + modetags = AllocVec(SIZE_MODELIST * sizeof(struct TagItem), MEMF_PUBLIC | MEMF_CLEAR); + + i = 0; + ForeachNode(csd->boardinfo + PSSO_BoardInfo_ResolutionsList, r) { + reslist[i * SIZE_RESLIST + 0].ti_Tag = aHidd_Sync_HDisp; + reslist[i * SIZE_RESLIST + 0].ti_Data = r->Width; + reslist[i * SIZE_RESLIST + 1].ti_Tag = aHidd_Sync_VDisp; + reslist[i * SIZE_RESLIST + 1].ti_Data = r->Height; + reslist[i * SIZE_RESLIST + 2].ti_Tag = aHidd_Sync_Description; + reslist[i * SIZE_RESLIST + 2].ti_Data = (IPTR)(csd->CardBase ? "RTGFX:%hx%v" : "UAEGFX:%hx%v"); + reslist[i * SIZE_RESLIST + 3].ti_Tag = aHidd_Sync_PixelClock; + reslist[i * SIZE_RESLIST + 3].ti_Data = r->Modes[CHUNKY]->PixelClock; + reslist[i * SIZE_RESLIST + 4].ti_Tag = TAG_DONE; + reslist[i * SIZE_RESLIST + 4].ti_Data = 0; + D(bug("%08x %d*%d\n", r, r->Width, r->Height)); + restags[i].ti_Tag = aHidd_Gfx_SyncTags; + restags[i].ti_Data = (IPTR)&reslist[i * SIZE_RESLIST]; + i++; + } + restags[i].ti_Tag = TAG_DONE; + restags[i].ti_Data = 0; + + gotmodes = 0; + k = 0; + j = 0; + for (i = 0; rgbtypelist[i]; i++) { + UBYTE rgbtype = rgbtypelist[i]; + WORD depth = getrtgdepth(1 << rgbtype); + if (!((1 << rgbtype) & RGBFB_SUPPORTMASK) || depth == 0 || !((1 << rgbtype) & supportedformats)) { + pflist[j].ti_Tag = TAG_DONE; + pflist[j].ti_Data = 0; + j++; + continue; + } + for (l = 0; formats[l].rgbformat; l++) { + if (formats[l].rgbformat == rgbtype) + break; + } + if (formats[l].rgbformat == 0) { + pflist[j].ti_Tag = TAG_DONE; + pflist[j].ti_Data = 0; + j++; + continue; + } + D(bug("RTGFORMAT=%d found. Depth=%d\n", rgbtype, depth)); + + if (gotmodes & (1 << (depth / 8))) { + D(bug("-> skipped\n")); + pflist[j].ti_Tag = TAG_DONE; + pflist[j].ti_Data = 0; + j++; + continue; + } + + gotmodes |= 1 << (depth / 8); + + modetags[k].ti_Tag = aHidd_Gfx_PixFmtTags; + modetags[k].ti_Data = (IPTR)&pflist[j]; + k++; + + pflist[j].ti_Tag = aHidd_PixFmt_RedShift; + pflist[j].ti_Data = formats[l].rs; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_GreenShift; + pflist[j].ti_Data = formats[l].gs; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_BlueShift; + pflist[j].ti_Data = formats[l].bs; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_AlphaShift; + pflist[j].ti_Data = formats[l].as; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_RedMask; + pflist[j].ti_Data = formats[l].rm; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_GreenMask; + pflist[j].ti_Data = formats[l].gm; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_BlueMask; + pflist[j].ti_Data = formats[l].bm; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_AlphaMask; + pflist[j].ti_Data = formats[l].am; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_CLUTMask; + pflist[j].ti_Data = 0x000000FF; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_CLUTShift; + pflist[j].ti_Data = 0; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_ColorModel; + pflist[j].ti_Data = depth <= 8 ? vHidd_ColorModel_Palette : vHidd_ColorModel_TrueColor; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_Depth; + pflist[j].ti_Data = depth; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_BytesPerPixel; + pflist[j].ti_Data = (depth + 7) / 8; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_BitsPerPixel; + pflist[j].ti_Data = depth; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_StdPixFmt; + pflist[j].ti_Data = vHidd_StdPixFmt_Native; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_BitMapType; + pflist[j].ti_Data = vHidd_BitMapType_Chunky; + j++; + pflist[j].ti_Tag = aHidd_PixFmt_SwapPixelBytes; + pflist[j].ti_Data = formats[l].endianswap; + j++; + pflist[j].ti_Tag = TAG_DONE; + pflist[j].ti_Data = 0; + j++; + } + + modetags[k].ti_Tag = aHidd_Sync_HMin; + modetags[k].ti_Data = 112; + k++; + modetags[k].ti_Tag = aHidd_Sync_VMin; + modetags[k].ti_Data = 112; + k++; + modetags[k].ti_Tag = aHidd_Sync_HMax; + modetags[k].ti_Data = 16384; + k++; + modetags[k].ti_Tag = aHidd_Sync_VMax; + modetags[k].ti_Data = 16384; + k++; + modetags[k].ti_Tag = TAG_MORE; + modetags[k].ti_Data = (IPTR)restags; + + mytags[0].ti_Data = (IPTR)modetags; + + EnterFunc(bug("UAEGFX::New() tags=%x\n", mytags)); + + mymsg.mID = msg->mID; + mymsg.attrList = mytags; + msg = &mymsg; + + /* Register gfxmodes */ + o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + if (NULL != o) + { + struct gfx_data *data = OOP_INST_DATA(cl, o); + HIDDT_ModeID *midp; + + D(bug("UAEGFX::New(): Got object from super\n")); + NewList((struct List *)&data->bitmaps); + csd->initialized = 1; + csd->spritecolors = 16; + + csd->superforward = TRUE; + midp = HIDD_Gfx_QueryModeIDs(o, NULL); + for (i = 0; midp[i] != vHidd_ModeID_Invalid; i++) { + OOP_Object *sync, *pf; + HIDDT_ModeID mid = midp[i]; + IPTR dwidth, dheight; + struct RTGMode *node1, *node2; + ULONG modeid, rtgmodeid, p96mode; + + if (!HIDD_Gfx_GetMode(o, mid, &sync, &pf)) + continue; + OOP_GetAttr(sync, aHidd_Sync_HDisp, &dwidth); + OOP_GetAttr(sync, aHidd_Sync_VDisp, &dheight); + + DB2(bug("w=%d h=%d mode=%08x sync=%x pf=%x\n", dwidth, dheight, mid, sync, pf)); + + modeid = vHidd_ModeID_Invalid; + ForeachNode(csd->boardinfo + PSSO_BoardInfo_ResolutionsList, r) { + if (r->Width == dwidth && r->Height == dheight) { + modeid = r->DisplayID; + break; + } + } + if (modeid == vHidd_ModeID_Invalid) { + D(bug("w=%d h=%d not found!\n", dwidth, dheight)); + continue; + } + + p96mode = getrtgformat(csd, pf); + rtgmodeid = (modeid & 0x00ff0000) | 0x1000 | (p96mode << 8); + + ForeachNode(&csd->rtglist, node2) { + if (node2->width == dwidth && node2->height == dheight && node2->modeid == rtgmodeid) + break; + } + if (node2->node.ln_Succ != NULL) { + D(bug("w=%d h=%d mode=%08x already found!\n", dwidth, dheight, rtgmodeid)); + continue; + } + + node1 = AllocMem(sizeof(struct RTGMode), MEMF_CLEAR); + node1->width = dwidth; + node1->height = dheight; + node1->pf = pf; + node1->sync = sync; + node1->modeid = rtgmodeid; + AddTail(&csd->rtglist, &node1->node); + + DB2(bug("Added %dx%d %08x %d\n", node1->width, node1->height, node1->modeid, p96mode)); + } + HIDD_Gfx_ReleaseModeIDs(o, midp); + csd->superforward = FALSE; + + } + + FreeVec(restags); + FreeVec(reslist); + FreeVec(pflist); + FreeVec(modetags); + + ReturnPtr("UAEGFX::New", OOP_Object *, o); +} + +/********** GfxHidd::Dispose() ******************************/ +OOP_Object *UAEGFXCl__Hidd_Gfx__CreateObject(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CreateObject *msg) +{ + OOP_Object *object = NULL; + + EnterFunc(bug("UAEGFX::CreateObject()\n")); + + if (msg->cl == CSD(cl)->basebm) + { + struct uaegfx_staticdata *csd = CSD(cl); + HIDDT_ModeID modeid; + struct pHidd_Gfx_CreateObject p; + struct TagItem tags[] = + { + { TAG_IGNORE, TAG_IGNORE }, /* Placeholder for aHidd_BitMap_ClassPtr */ + { TAG_MORE, (IPTR)msg->attrList } + }; + + modeid = (HIDDT_ModeID)GetTagData(aHidd_BitMap_ModeID, vHidd_ModeID_Invalid, msg->attrList); + if (modeid != vHidd_ModeID_Invalid) { + tags[0].ti_Tag = aHidd_BitMap_ClassPtr; + tags[0].ti_Data = (IPTR)CSD(cl)->bmclass; + } + p.mID = msg->mID; + p.cl = msg->cl; + p.attrList = tags; + + object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)&p); + } + else + object = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + + ReturnPtr("UAEGFX::CreateObject", OOP_Object *, object); +} + +VOID UAEGFXCl__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + ULONG idx; + + //bug("UAEGFXCl__Root__Get %x\n", msg->attrID); + + if (IS_GFX_ATTR(msg->attrID, idx)) + { + //bug("=%x\n", idx); + switch (idx) + { + case aoHidd_Gfx_HWSpriteTypes: + *msg->storage = csd->hardwaresprite ? vHidd_SpriteType_3Plus1 : 0; + return; + case aoHidd_Gfx_SupportsHWCursor: + *msg->storage = csd->hardwaresprite; + return; + case aoHidd_Gfx_NoFrameBuffer: + *msg->storage = TRUE; + return; + case aoHidd_Gfx_IsWindowed: + *msg->storage = FALSE; + return; + case aoHidd_Gfx_DriverName: + *msg->storage = (IPTR)"UAEGFX"; + return; + } + } + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); +} + +VOID UAEGFXCl__Root__Set(OOP_Class *cl, OOP_Object *obj, struct pRoot_Set *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct TagItem *tag, *tstate; + + tstate = msg->attrList; + while((tag = NextTagItem(&tstate))) + { + ULONG idx; + D(bug("UAEGFXCl__Root__Set %x\n", tag->ti_Tag)); + if (IS_GFX_ATTR(tag->ti_Tag, idx)) { + D(bug("->%d\n", idx)); + switch(idx) + { + case aoHidd_Gfx_ActiveCallBack: + csd->acb = (void *)tag->ti_Data; + break; + + case aoHidd_Gfx_ActiveCallBackData: + csd->acbdata = (APTR)tag->ti_Data; + break; + } + } + } + OOP_DoSuperMethod(cl, obj, (OOP_Msg)msg); +} +#if 0 +ULONG UAEGFXCl__Hidd_Gfx__MakeViewPort(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_MakeViewPort *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + + csd->vpe = NULL; + if (!msg) + return MVP_OK; + bug("makeviewport %p\n", msg->Data->vpe); + csd->vpe = msg->Data->vpe; + return MVP_OK; +} + +void UAEGFXCl__Hidd_Gfx__CleanViewPort(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CleanViewPort *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + + csd->vpe = NULL; + bug("cleanviewport\n"); +} +#endif + +static void doshow(struct uaegfx_staticdata *csd, OOP_Object *bm, struct ViewPort *vp, BOOL offonly) +{ + struct IntuitionBase *ib = (struct IntuitionBase*)csd->cs_IntuitionBase; + struct ViewPort *vpi = NULL; + + if (ib->FirstScreen) + vpi = &ib->FirstScreen->ViewPort; + + D(bug("doshow b=%p vp=%p vpi=%p acb=%p acbd=%p\n", bm, vp, vpi, csd->acb, csd->acbdata)); + + if (bm && vpi == vp) { + /* we are topmost screen -> show our display */ + IPTR tags[] = {aHidd_BitMap_Visible, TRUE, TAG_DONE}; + + if (offonly) + return; + + OOP_SetAttrs(bm, (struct TagItem *)tags); + + if (csd->acb) + csd->acb(csd->acbdata, NULL); + + } else if (bm) { + /* we are not topmost -> turn off our display */ + IPTR tags[] = {aHidd_BitMap_Visible, FALSE, TAG_DONE}; + OOP_SetAttrs(bm, (struct TagItem *)tags); + } else { + + LOCK_HW + + /* no display */ + SetDisplay(csd, FALSE); + SetSwitch(csd, FALSE); + + UNLOCK_HW + } +} + +OOP_Object *UAEGFXCl__Hidd_Gfx__Show(OOP_Class *cl, OOP_Object *c, struct pHidd_Gfx_Show *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + + doshow(csd, msg->bitMap, csd->viewport, FALSE); + return msg->bitMap; +} + +ULONG UAEGFXCl__Hidd_Gfx__PrepareViewPorts(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_ShowViewPorts *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct HIDD_ViewPortData *vpd = msg->Data; + OOP_Object *bm = NULL; + struct ViewPort *vp = NULL; + + if (vpd) { + bm = vpd->Bitmap; + if (vpd->vpe) + vp = vpd->vpe->ViewPort; + } + csd->viewport = vp; + doshow(csd, bm, vp, FALSE); + + bug("PrepareViewPorts viewport=%p\n", csd->viewport); + return MCOP_OK; +} + +ULONG UAEGFXCl__Hidd_Gfx__ShowViewPorts(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_ShowViewPorts *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + struct HIDD_ViewPortData *vpd = msg->Data; + OOP_Object *bm = NULL; + struct ViewPort *vp = NULL; + + if (vpd) { + bm = vpd->Bitmap; + if (vpd->vpe) + vp = vpd->vpe->ViewPort; + } + doshow(csd, bm, vp, FALSE); + return TRUE; +} + +VOID UAEGFXCl__Hidd_Gfx__CopyBox(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CopyBox *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + HIDDT_DrawMode mode = GC_DRMD(msg->gc); + struct bm_data *sdata = NULL; + struct bm_data *ddata = NULL; + struct RenderInfo risrc, ridst; + + if (OOP_OCLASS(msg->src) == csd->bmclass) sdata = OOP_INST_DATA(OOP_OCLASS(msg->src), msg->src); + if (OOP_OCLASS(msg->dest) == csd->bmclass) ddata = OOP_INST_DATA(OOP_OCLASS(msg->dest), msg->dest); + + if (!sdata || !ddata) + { + //kprintf("==== copybox: unknown bitmap %p %p drawmode %d\n", sdata, ddata, mode); + //if (!sdata) kprintf(" src: %s\n", OOP_OCLASS(msg->src)->ClassNode.ln_Name ? OOP_OCLASS(msg->src)->ClassNode.ln_Name : "unknown"); + //if (!ddata) kprintf(" dst: %s\n", OOP_OCLASS(msg->dest)->ClassNode.ln_Name ? OOP_OCLASS(msg->dest)->ClassNode.ln_Name : "unknown"); + + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + return; + } + + if (sdata->rgbformat != ddata->rgbformat) { + //kprintf("==== ocpybox: format mismatch %d %d drawmode %d\n", sdata->rgbformat, ddata->rgbformat, mode); + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + return; + } + + LOCK_MULTI_BITMAP + LOCK_BITMAP(sdata) + LOCK_BITMAP(ddata) + UNLOCK_MULTI_BITMAP + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + if (!sdata->invram || !ddata->invram) + { + /* Blit from VRAM to RAM or from RAM to VRAM */ + +#if 0 + kprintf("== VRAM <-> RAM blit bpp %d\n", sdata->bytesperpixel); + kprintf("%p to %p %d,%d -> %d,%d %d x %d modulo %d %d\n", + sdata->VideoData, ddata->VideoData, + msg->srcX, msg->srcY, msg->destX, msg->destY, msg->width, msg->height, + sdata->bytesperline, + ddata->bytesperline); +#endif + + if (mode == vHidd_GC_DrawMode_Copy) + { + switch(sdata->bytesperpixel) + { + case 1: + HIDD_BM_CopyMemBox8(msg->dest, + sdata->VideoData, + msg->srcX, + msg->srcY, + ddata->VideoData, + msg->destX, + msg->destY, + msg->width, + msg->height, + sdata->bytesperline, + ddata->bytesperline); + break; + + case 2: + HIDD_BM_CopyMemBox16(msg->dest, + sdata->VideoData, + msg->srcX, + msg->srcY, + ddata->VideoData, + msg->destX, + msg->destY, + msg->width, + msg->height, + sdata->bytesperline, + ddata->bytesperline); + break; + + case 3: + HIDD_BM_CopyMemBox24(msg->dest, + sdata->VideoData, + msg->srcX, + msg->srcY, + ddata->VideoData, + msg->destX, + msg->destY, + msg->width, + msg->height, + sdata->bytesperline, + ddata->bytesperline); + break; + + case 4: + HIDD_BM_CopyMemBox32(msg->dest, + sdata->VideoData, + msg->srcX, + msg->srcY, + ddata->VideoData, + msg->destX, + msg->destY, + msg->width, + msg->height, + sdata->bytesperline, + ddata->bytesperline); + break; + + } /* switch(data->bytesperpix) */ + + } /* if (mode == vHidd_GC_DrawMode_Copy) */ + else + { + //if (mode == vHidd_GC_DrawMode_Clear) kprintf(" clear blit %d x %d done by superclass\n", msg->width, msg->height); + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + } + } /* if (!sdata->invram || !ddata->invram) */ + else + { + //if (mode == vHidd_GC_DrawMode_Clear) kprintf(" clear blit %d x %d done by me\n", msg->width, msg->height); + + makerenderinfo(csd, &risrc, sdata); + makerenderinfo(csd, &ridst, ddata); + + LOCK_HW + + if (!BlitRectNoMaskComplete(csd, &risrc, &ridst, + msg->srcX, msg->srcY, msg->destX, msg->destY, + msg->width, msg->height, modetable[mode], sdata->rgbformat)) + { + //kprintf("== unhandled blit %d x %d drawmode %d. super must help\n", msg->width, msg->height, mode); + OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); + } + + UNLOCK_HW + } + + UNLOCK_BITMAP(sdata) + UNLOCK_BITMAP(ddata) + +} + +BOOL UAEGFXCl__Hidd_Gfx__CopyBoxMasked(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CopyBoxMasked *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + + LOCK_HW + WaitBlitter(csd); + UNLOCK_HW + + return OOP_DoSuperMethod(cl, o, (OOP_Msg)msg); +} + +BOOL UAEGFXCl__Hidd_Gfx__SetCursorShape(OOP_Class *cl, OOP_Object *shape, struct pHidd_Gfx_SetCursorShape *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + OOP_Object *cm = NULL; + IPTR width, height; + WORD x, y, hiressprite, i; + UWORD *p; + ULONG flags; + + OOP_GetAttr(msg->shape, aHidd_BitMap_Width, &width); + OOP_GetAttr(msg->shape, aHidd_BitMap_Height, &height); + OOP_GetAttr(msg->shape, aHidd_BitMap_ColorMap, (IPTR*)&cm); + + LOCK_HW + + if (cm) { + for (i = 0; i < 3; i++) { + HIDDT_Color c; + HIDD_CM_GetColor(cm, i + 1, &c); + SetSpriteColor(csd, i, c.red, c.green, c.blue); + } + } + Forbid(); + pb(csd->boardinfo + PSSO_BoardInfo_MouseXOffset, msg->xoffset); + pb(csd->boardinfo + PSSO_BoardInfo_MouseYOffset, msg->yoffset); + p = (UWORD*)gp(csd->boardinfo + PSSO_BoardInfo_MouseImage); + if (p == NULL || width != csd->sprite_width || height != csd->sprite_height) { + FreeVec(p); + p = AllocVec(4 + 4 + ((width + 15) & ~15) / 8 * height * 2, MEMF_CLEAR | MEMF_PUBLIC); + pp(csd->boardinfo + PSSO_BoardInfo_MouseImage, p); + if (!p) { + Permit(); + + UNLOCK_HW + return FALSE; + } + csd->sprite_width = width; + csd->sprite_height = height; + } + + flags = gl(csd->boardinfo + PSSO_BoardInfo_Flags); + flags &= ~(1 << BIB_HIRESSPRITE); + hiressprite = 1; + if (width > 16) { + flags |= 1 << BIB_HIRESSPRITE; + hiressprite = 2; + } + pl(csd->boardinfo + PSSO_BoardInfo_Flags, flags); + + pb(csd->boardinfo + PSSO_BoardInfo_MouseWidth, width / hiressprite); + pb(csd->boardinfo + PSSO_BoardInfo_MouseHeight, height); + + p += 2 * hiressprite; + for(y = 0; y < height; y++) { + UWORD pix1 = 0, pix2 = 0, xcnt = 0; + for(x = 0; x < width; x++) { + UBYTE c = HIDD_BM_GetPixel(msg->shape, x, y); + pix1 <<= 1; + pix2 <<= 1; + pix1 |= (c & 1) ? 1 : 0; + pix2 |= (c & 2) ? 1 : 0; + xcnt++; + if (xcnt == 15) { + xcnt = 0; + p[x / 16] = pix1; + p[width / 16 + x / 16] = pix2; + } + } + p += (width / 16) * 2; + } + Permit(); + SetSpriteImage(csd); + + UNLOCK_HW + + return TRUE; +} + +BOOL UAEGFXCl__Hidd_Gfx__SetCursorPos(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorPos *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + + LOCK_HW + pw(csd->boardinfo + PSSO_BoardInfo_MouseX, msg->x + (BYTE)csd->boardinfo[PSSO_BoardInfo_MouseXOffset]); + pw(csd->boardinfo + PSSO_BoardInfo_MouseY, msg->y + (BYTE)csd->boardinfo[PSSO_BoardInfo_MouseYOffset]); + SetSpritePosition(csd); + UNLOCK_HW + + return TRUE; +} +VOID UAEGFXCl__Hidd_Gfx__SetCursorVisible(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_SetCursorVisible *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + + LOCK_HW + SetSprite(csd, msg->visible); + UNLOCK_HW +} + +BOOL UAEGFXCl__Hidd_Gfx__CheckMode(OOP_Class *cl, OOP_Object *o, struct pHidd_Gfx_CheckMode *msg) +{ + struct uaegfx_staticdata *csd = CSD(cl); + IPTR width, height, bpp; + + OOP_GetAttr(msg->sync, aHidd_Sync_HDisp, &width); + OOP_GetAttr(msg->sync, aHidd_Sync_VDisp, &height); + OOP_GetAttr(msg->pixFmt, aHidd_PixFmt_BytesPerPixel, &bpp); + if (width > csd->maxwidth[bpp]) + return FALSE; + if (height > csd->maxheight[bpp]) + return FALSE; + return width * height * bpp < csd->vram_size; +} + + +static void freeattrbases(LIBBASETYPEPTR LIBBASE, struct uaegfx_staticdata *csd) +{ + OOP_ReleaseAttrBase(IID_Hidd); + OOP_ReleaseAttrBase(IID_Hidd_BitMap); + OOP_ReleaseAttrBase(IID_Hidd_BitMap_UAE); + OOP_ReleaseAttrBase(IID_Hidd_GC); + OOP_ReleaseAttrBase(IID_Hidd_Sync); + OOP_ReleaseAttrBase(IID_Hidd_Gfx); + OOP_ReleaseAttrBase(IID_Hidd_PixFmt); + OOP_ReleaseAttrBase(IID_Hidd_ColorMap); +} + +AROS_INTP(rtg_vblank); + +struct P96RTGmode +{ + UWORD w, h, id; + ULONG clock; + UWORD htotal, vtotal; + UWORD hborder, vborder; + UWORD hpos, vpos; + UWORD hsync, vsync; + UBYTE flags; +}; + +static const struct P96RTGmode rtgmodes[] = +{ + { 320, 240, 1, 13020000, 408, 262, 0, 0, 32, 5, 24, 1, GMF_HPOLARITY | GMF_VPOLARITY | GMF_DOUBLESCAN }, + { 640, 480, 3, 25060000, 800, 525, 0, 0, 40, 11, 88, 2, GMF_HPOLARITY | GMF_VPOLARITY }, + { 800, 600, 4, 32010000, 1024, 625, 0, 0, 56, 1, 40, 2, 0 }, + { 1024, 768, 5, 64430000, 1336, 800, 0, 0, 48, 4, 112, 5, GMF_HPOLARITY | GMF_VPOLARITY }, + { 1152, 900, 6, 85010000, 1496, 973, 0, 0, 48, 5, 40, 4, GMF_HPOLARITY | GMF_VPOLARITY }, + { 1440, 900, 7, 106360000, 1904, 932, 0, 0, 80, 0, 0, 10, GMF_HPOLARITY | GMF_VPOLARITY }, + { 0 } +}; +/* real RTG only */ +static BOOL PopulateModeInfo(struct uaegfx_staticdata *csd, struct LibResolution *res, const struct P96RTGmode *mode) +{ + UWORD rgbformat; + BOOL ok = FALSE; + + for (rgbformat = 0; rgbformat < RGBFB_MaxFormats; rgbformat++) { + ULONG clockindex; + UBYTE depth, index; + struct ModeInfo *mi; + UWORD maxhval, maxvval, maxhres, maxvres; + + if (!((1 << rgbformat) & RGBFB_SUPPORTMASK)) + continue; + if (!((1 << rgbformat) & gw(csd->boardinfo + PSSO_BoardInfo_RGBFormats))) + continue; + depth = getrtgdepth(1 << rgbformat); + index = (depth + 7) / 8; + if (res->Modes[index]) + continue; + + maxhval = gw(csd->boardinfo + PSSO_BoardInfo_MaxHorValue + index * 2); + maxvval = gw(csd->boardinfo + PSSO_BoardInfo_MaxVerValue + index * 2); + maxhres = gw(csd->boardinfo + PSSO_BoardInfo_MaxHorResolution + index * 2); + maxvres = gw(csd->boardinfo + PSSO_BoardInfo_MaxVerResolution + index * 2); + + if (mode->htotal > maxhval || mode->vtotal > maxvval || + mode->w > maxhres || mode->h > maxvres) + continue; + + mi = AllocMem(sizeof(struct ModeInfo), MEMF_CLEAR | MEMF_PUBLIC); + if (!mi) + continue; + mi->OpenCount = 1; + mi->Active = TRUE; + mi->Width = mode->w; + mi->Height = mode->h; + mi->Depth = depth; + mi->HorTotal = mode->htotal; + mi->VerTotal = mode->vtotal; + mi->HorBlankSize = mode->hborder; + mi->VerBlankSize = mode->vborder; + mi->HorSyncStart = mode->hpos; + mi->VerSyncStart = mode->vpos; + mi->HorSyncSize = mode->hsync; + mi->VerSyncSize = mode->vsync; + mi->Flags = mode->flags; + clockindex = ResolvePixelClock(csd, mi, mode->clock, rgbformat); + mi->PixelClock = GetPixelClock(csd, mi, clockindex, rgbformat); + DRTG(bug("%d,%p: %dx%dx%d ci=%d clk=%d (%d/%d)\n", + index, mi, mi->Width, mi->Height, mi->Depth, + clockindex, mi->PixelClock, mi->Numerator, mi->Denominator)); + res->Modes[index] = mi; + ok = TRUE; + } + return ok; +} +static void PopulateResolutionList(struct uaegfx_staticdata *csd) +{ + struct LibResolution *node; + UWORD cnt; + + NEWLIST((csd->boardinfo + PSSO_BoardInfo_ResolutionsList)); + for (cnt = 0; rtgmodes[cnt].clock; cnt++) { + const struct P96RTGmode *mode = &rtgmodes[cnt]; + node = AllocMem(sizeof(struct LibResolution), MEMF_CLEAR | MEMF_PUBLIC); + if (!node) + break; + node->Width = mode->w; + node->Height = mode->h; + node->DisplayID = 0x50001000 | (mode->id << 16); + node->BoardInfo = csd->boardinfo; + if (PopulateModeInfo(csd, node, mode)) + AddTail((struct List*)(csd->boardinfo + PSSO_BoardInfo_ResolutionsList), (struct Node*)node); + else + FreeMem(node, sizeof(struct LibResolution)); + } +} + +static int openall(struct uaegfx_staticdata *csd) +{ + if ((csd->cs_UtilityBase = TaggedOpenLibrary(TAGGEDOPEN_UTILITY))) { + if ((csd->cs_IntuitionBase = TaggedOpenLibrary(TAGGEDOPEN_INTUITION))) { + return TRUE; + } + } + return FALSE; +} +static void freeall(struct uaegfx_staticdata *csd) +{ + CloseLibrary(csd->cs_IntuitionBase); + CloseLibrary(csd->cs_UtilityBase); + FreeMem(csd->vmem, sizeof(struct MemHeader)); + csd->vmem = NULL; + FreeVec(csd->boardinfo); + csd->boardinfo = NULL; +} + +static void P96DebugInfo(struct uaegfx_staticdata *csd) +{ + UBYTE i; + DRTG(bug("Name:'%s'\n", + gl(csd->boardinfo + PSSO_BoardInfo_BoardName))); + DRTG(bug("Reg:%08x IO:%08x\n", + gl(csd->boardinfo + PSSO_BoardInfo_RegisterBase), + gl(csd->boardinfo + PSSO_BoardInfo_MemoryIOBase))); + DRTG(bug("BoardType:%d GCType:%d PCType:%d BPC:%d Flags:%08x\n", + gl(csd->boardinfo + PSSO_BoardInfo_BoardType), + gl(csd->boardinfo + PSSO_BoardInfo_GraphicsControllerType), + gl(csd->boardinfo + PSSO_BoardInfo_PaletteChipType), + gw(csd->boardinfo + PSSO_BoardInfo_BitsPerCannon), + gl(csd->boardinfo + PSSO_BoardInfo_Flags))); + for (i = 0; i < MAXMODES; i++) { + DRTG(bug("%d: HV:%4d VV: %4d HR:%4d VR:%4d C:%d\n", i, + gw(csd->boardinfo + PSSO_BoardInfo_MaxHorValue + i * 2), + gw(csd->boardinfo + PSSO_BoardInfo_MaxVerValue + i * 2), + gw(csd->boardinfo + PSSO_BoardInfo_MaxHorResolution + i * 2), + gw(csd->boardinfo + PSSO_BoardInfo_MaxVerResolution + i * 2), + gl(csd->boardinfo + PSSO_BoardInfo_PixelClockCount + i * 4))); + } +} + +static BOOL P96Init(struct uaegfx_staticdata *csd, struct Library *lib) +{ + DRTG(bug("P96GFX: attempting to init '%s'\n", lib->lib_Node.ln_Name)); + pl(csd->boardinfo + PSSO_BoardInfo_CardBase, (ULONG)lib); + csd->CardBase = lib; + InitRTG(csd->boardinfo); + if (FindCard(csd)) { + DRTG(bug("P96GFX: FindCard succeeded\n")); + if (InitCard(csd)) { + DRTG(bug("P96GFX: InitCard succeeded\n")); + SetInterrupt(csd, FALSE); + /* Without this card may not be in linear memory map mode. */ + SetMemoryMode(csd, RGBFB_CLUT); + P96DebugInfo(csd); + return TRUE; + } + } + pl(csd->boardinfo + PSSO_BoardInfo_CardBase, 0); + csd->CardBase = NULL; + return FALSE; +} + + +BOOL Init_UAEGFXClass(LIBBASETYPEPTR LIBBASE) +{ + struct uaegfx_staticdata *csd = &LIBBASE->csd; + struct MemChunk *mc; + UBYTE i; + struct Interrupt *intr; + struct Node *node; + + if (!(SysBase->AttnFlags & AFF_68020)) + return FALSE; + + D(bug("Init_UAEGFXClass\n")); + if (!openall(csd)) { + freeall(csd); + return FALSE; + } + + csd->boardinfo = AllocVec(PSSO_BoardInfo_SizeOf + PSSO_BitMapExtra_Last + sizeof(struct ModeInfo), MEMF_CLEAR | MEMF_PUBLIC); + if (!csd->boardinfo) { + freeall(csd); + return FALSE; + } + NEWLIST((struct List*)(csd->boardinfo + PSSO_BoardInfo_ResolutionsList)); + NEWLIST((struct List*)(csd->boardinfo + PSSO_BoardInfo_BitMapList)); + NEWLIST((struct List*)(csd->boardinfo + PSSO_BoardInfo_MemList)); + NEWLIST((struct List*)(csd->boardinfo + PSSO_BoardInfo_WaitQ)); + csd->bitmapextra = csd->boardinfo + PSSO_BoardInfo_SizeOf; + csd->fakemodeinfo = (struct ModeInfo*)(csd->boardinfo + PSSO_BoardInfo_SizeOf + PSSO_BitMapExtra_Last); + pl(csd->boardinfo + PSSO_BoardInfo_BitMapExtra, (ULONG)csd->bitmapextra); + pl(csd->boardinfo + PSSO_BoardInfo_ExecBase, (ULONG)SysBase); + pl(csd->boardinfo + PSSO_BoardInfo_UtilBase, (ULONG)csd->cs_UtilityBase); + InitSemaphore((struct SignalSemaphore*)(csd->boardinfo + PSSO_BoardInfo_BoardLock)); + intr = (struct Interrupt*)(csd->boardinfo + PSSO_BoardInfo_HardInterrupt); + intr->is_Code = (APTR)rtg_vblank; + intr->is_Data = csd->boardinfo; + intr->is_Node.ln_Name = "RTG VBlank"; + intr->is_Node.ln_Pri = 0; + intr->is_Node.ln_Type = NT_INTERRUPT; + intr = (struct Interrupt*)(csd->boardinfo + PSSO_BoardInfo_SoftInterrupt); + intr->is_Code = (APTR)rtg_vblank; + intr->is_Data = csd->boardinfo; + intr->is_Node.ln_Name = "RTG VBlank"; + intr->is_Node.ln_Pri = 0; + intr->is_Node.ln_Type = NT_INTERRUPT; + + Forbid(); + ForeachNode(&SysBase->LibList.lh_Head, node) { + struct Library *lib = (struct Library*)node; + char *name = node->ln_Name; + int len = strlen(name); + if (len > 5 && !stricmp(name + len - 5, ".card")) { + BOOL ret; + Permit(); + ret = P96Init(csd, lib); + Forbid(); + if (ret) + break; + DRTG(bug("P96GFX: init failed\n")); + } + } + Permit(); + + if (!csd->CardBase) { + csd->uaeromvector = (APTR)(0xf00000 + 0xff60); + if ((gl(csd->uaeromvector) & 0xff00ffff) != 0xa0004e75) { + D(bug("UAE boot ROM entry point not found. UAEGFX not enabled.\n")); + freeall(csd); + return FALSE; + } + if (!FindCard(csd)) { + D(bug("UAEGFX: FindCard() returned false\n")); + freeall(csd); + return FALSE; + } + D(bug("UAEGFX: FindCard done\n")); + InitCard(csd); + csd->hardwaresprite = (gl(csd->boardinfo + PSSO_BoardInfo_Flags) & (1 << BIB_HARDWARESPRITE)) && SetSprite(csd, FALSE); + } else { + PopulateResolutionList(csd); + csd->hardwaresprite = gl(csd->boardinfo + PSSO_BoardInfo_Flags) & (1 << BIB_HARDWARESPRITE); + } + + if (IsListEmpty((struct List*)(csd->boardinfo + PSSO_BoardInfo_ResolutionsList))) { + D(bug("Resolutionlist is empty, init failed.\n")); + freeall(csd); + return FALSE; + } + for (i = 0; i < MAXMODES; i++) { + csd->maxwidth[i] = gw(csd->boardinfo + PSSO_BoardInfo_MaxHorResolution + i * 2); + csd->maxheight[i] = gw(csd->boardinfo + PSSO_BoardInfo_MaxVerResolution + i * 2); + } + + D(bug("InitCard done\n")); + + DRTG(bug("hardware sprite: %d\n", csd->hardwaresprite)); + + csd->vram_start = (UBYTE*)gl(csd->boardinfo + PSSO_BoardInfo_MemoryBase); + + +#if 1 + csd->vram_size = gl(csd->boardinfo + PSSO_BoardInfo_MemorySize); +#else + /* REMOVEME: 4MB hack (used for easier debug of vram <-> ram swapping) !!!!*/ + csd->vram_size = 4 * 1024 * 1024; /* gl(csd->boardinfo + PSSO_BoardInfo_MemorySize); */ + /* REMOVEME: 4MB Hack (used for easier debug of vram <-> ram swapping) !!!!*/ +#endif + + DRTG(bug("P96RTG VRAM found at %08x size %08x\n", csd->vram_start, csd->vram_size)); + mc = (struct MemChunk*)csd->vram_start; + csd->vmem = AllocVec(sizeof(struct MemHeader), MEMF_CLEAR | MEMF_PUBLIC); + csd->vmem->mh_Node.ln_Type = NT_MEMORY; + csd->vmem->mh_First = mc; + csd->vmem->mh_Lower = (APTR)mc; + csd->vmem->mh_Upper = (APTR)((ULONG)mc + csd->vram_size); + csd->vmem->mh_Free = csd->vram_size; + mc->mc_Next = NULL; + mc->mc_Bytes = csd->vmem->mh_Free; + + __IHidd = OOP_ObtainAttrBase(IID_Hidd); + __IHidd_BitMap = OOP_ObtainAttrBase(IID_Hidd_BitMap); + __IHidd_BitMap_UAE = OOP_ObtainAttrBase(IID_Hidd_BitMap_UAE); + __IHidd_GC = OOP_ObtainAttrBase(IID_Hidd_GC); + __IHidd_Sync = OOP_ObtainAttrBase(IID_Hidd_Sync); + __IHidd_Gfx = OOP_ObtainAttrBase(IID_Hidd_Gfx); + __IHidd_PixFmt = OOP_ObtainAttrBase(IID_Hidd_PixFmt); + __IHidd_ColorMap = OOP_ObtainAttrBase(IID_Hidd_ColorMap); + + HiddBitMapBase = OOP_GetMethodID(IID_Hidd_BitMap, 0); + HiddColorMapBase = OOP_GetMethodID(IID_Hidd_ColorMap, 0); + HiddGfxBase = OOP_GetMethodID(IID_Hidd_Gfx, 0); + + if (!__IHidd || !__IHidd_BitMap || !__IHidd_BitMap_UAE || !__IHidd_GC || + !__IHidd_Sync || !__IHidd_Gfx || !__IHidd_PixFmt || !__IHidd_ColorMap) + { + D(bug("Init_UAEGFXClass fail\n")); + freeattrbases(LIBBASE, csd); + freeall(csd); + return FALSE; + } + + DRTG(bug("P96RTG done\n")); + return TRUE; +} + +static int Expunge_UAEGFXClass(LIBBASETYPEPTR LIBBASE) +{ + struct uaegfx_staticdata *csd = &LIBBASE->csd; + D(bug("Expunge_UAEGFXClass\n")); + freeattrbases(LIBBASE, csd); + freeall(csd); + return TRUE; +} + +ADD2EXPUNGELIB(Expunge_UAEGFXClass, 1) + +#undef SysBase + +AROS_INTH1(rtg_vblank, APTR, boardinfo) +{ + AROS_INTFUNC_INIT + + return 0; + + AROS_INTFUNC_EXIT + +} + diff --git a/arch/m68k-amiga/hidd/uaegfx/uaegfx_intern.h b/arch/m68k-amiga/hidd/uaegfx/uaegfx_intern.h new file mode 100644 index 0000000000..b6a5c2a580 --- /dev/null +++ b/arch/m68k-amiga/hidd/uaegfx/uaegfx_intern.h @@ -0,0 +1,123 @@ +#ifndef HIDD_UAEGFX_H +#define HIDD_UAEGFX_H + +#include +#include +#include + +#include "uaegfx_hidd.h" + +#define __IHidd (csd->hiddAttrBase) +#define __IHidd_BitMap (csd->hiddBitMapAttrBase) +#define __IHidd_BitMap_UAE (csd->hiddUAEGFXBitMapAttrBase) +#define __IHidd_GC (csd->hiddGCAttrBase) +#define __IHidd_Sync (csd->hiddSyncAttrBase) +#define __IHidd_PixFmt (csd->hiddPixFmtAttrBase) +#define __IHidd_Gfx (csd->hiddGfxAttrBase) +//#define __IHidd_Attr (csd->hiddAttrBase) +#define __IHidd_ColorMap (csd->hiddColorMapAttrBase) + +#define HiddBitMapBase (csd->hiddBitMapBase) +#define HiddColorMapBase (csd->hiddColorMapBase) +#define HiddGfxBase (csd->hiddGfxBase) + +#include + +#define UtilityBase ((csd)->cs_UtilityBase) + +struct RTGMode +{ + struct Node node; + ULONG modeid; + UWORD width, height; + OOP_Object *pf; + OOP_Object *sync; +}; + +struct uaegfx_staticdata +{ + OOP_Class *basebm; /* baseclass for CreateObject */ + OOP_Class *gfxclass; + OOP_Class *bmclass; + + OOP_AttrBase hiddAttrBase; + OOP_AttrBase hiddBitMapAttrBase; + OOP_AttrBase hiddUAEGFXBitMapAttrBase; + OOP_AttrBase hiddGCAttrBase; + OOP_AttrBase hiddSyncAttrBase; + OOP_AttrBase hiddPixFmtAttrBase; + OOP_AttrBase hiddGfxAttrBase; + OOP_AttrBase hiddColorMapAttrBase; + + OOP_MethodID hiddBitMapBase; + OOP_MethodID hiddColorMapBase; + OOP_MethodID hiddGfxBase; + + struct List rtglist; + struct List bitmaplist; + struct Library *CardBase; + struct ExecBase *cs_SysBase; + struct Library *cs_IntuitionBase; + struct Library *cs_UtilityBase; + struct Library *cs_OOPBase; + struct bm_data *disp; + APTR uaeromvector; + ULONG rgbformat; + struct ModeInfo *modeinfo; + struct ModeInfo *fakemodeinfo; + UBYTE *boardinfo; + UBYTE *bitmapextra; + UBYTE *vram_start; + ULONG vram_size; + ULONG vram_used, fram_used; + struct MemHeader *vmem; + + WORD sprite_width, sprite_height; + BOOL hardwaresprite; + WORD spritecolors; + + BOOL initialized; + BOOL superforward; + + UWORD dwidth, dheight; + ULONG dmodeid; + + UWORD maxwidth[5]; + UWORD maxheight[5]; + + struct ViewPort *viewport; + void (*acb)(void *data, void *bm); + APTR acbdata; + + struct SignalSemaphore HWLock; + struct SignalSemaphore MultiBMLock; +}; + +struct UAEGFXclbase +{ + struct Library library; + + struct uaegfx_staticdata csd; + IPTR cs_SegList; +}; + +#undef CSD +#define CSD(cl) (&((struct UAEGFXclbase *)cl->UserData)->csd) + +#define SysBase (csd->cs_SysBase) +#define OOPBase (csd->cs_OOPBase) + +#define LOCK_HW {ObtainSemaphore(&(csd)->HWLock);} +#define UNLOCK_HW {ReleaseSemaphore(&(csd)->HWLock);} + +#define LOCK_MULTI_BITMAP {ObtainSemaphore(&(csd)->MultiBMLock);} +#define UNLOCK_MULTI_BITMAP {ReleaseSemaphore(&(csd)->MultiBMLock);} + +/* Private instance data for Gfx hidd class */ +struct gfx_data +{ + struct MinList bitmaps; /* Currently shown bitmap objects */ +}; + +#endif + diff --git a/arch/m68k-amiga/hidd/uaegfx/uaertg.c b/arch/m68k-amiga/hidd/uaegfx/uaertg.c new file mode 100644 index 0000000000..7350ce103e --- /dev/null +++ b/arch/m68k-amiga/hidd/uaegfx/uaertg.c @@ -0,0 +1,564 @@ +/* + Copyright © 1995-2017, The AROS Development Team. All rights reserved. + $Id$ +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "uaegfx_intern.h" +#include "uaegfx_bitmap.h" +#include "uaertg.h" +#include "p96call.h" + +static APTR gptr(struct uaegfx_staticdata *csd, WORD offset) +{ + APTR code = (APTR)((ULONG*)(((UBYTE*)(csd->boardinfo)) + offset))[0]; + D(bug("->RTG off=%d code=%p\n", (offset - (PSSO_BoardInfo_AllocCardMem)) / 4, code)); +#if 0 + UBYTE *board = gl(csd->boardinfo + PSSO_BoardInfo_MemoryBase); + bug("%08x: %08x %08x %08x %08x\n", + board, + gl(board + 0), + gl(board + 4), + gl(board + 8), + gl(board + 12)); +#endif + pw (csd->boardinfo + PSSO_BoardInfo_AROSFlag, 1); + return code; +} + +static AROS_UFH1(ULONG, RTGCall_Default, + AROS_UFHA(APTR, boardinfo, A0)) +{ + AROS_USERFUNC_INIT + + pw (boardinfo + PSSO_BoardInfo_AROSFlag, 0); + return 0; + + AROS_USERFUNC_EXIT +} + +/* Set fallback functions */ +void InitRTG(APTR boardinfo) +{ + UWORD i; + + for (i = PSSO_BoardInfo_AllocCardMem; i <= PSSO_BoardInfo_DeleteFeature; i += 4) + pl(boardinfo + i, (ULONG)RTGCall_Default); +} + +BOOL FindCard(struct uaegfx_staticdata *csd) +{ + if (csd->CardBase) + return AROS_LVO_CALL1(BOOL, + AROS_LCA(APTR, csd->boardinfo, A0), + struct Library*, csd->CardBase, 5, ); + else + return P96_LC1(BOOL, csd->uaeromvector, 16, + AROS_LCA(APTR, csd->boardinfo, A0)); +} +BOOL InitCard(struct uaegfx_staticdata *csd) +{ + if (csd->CardBase) + return AROS_LVO_CALL2(BOOL, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, NULL, A1), + struct Library*, csd->CardBase, 6, ); + else + return P96_LC2(BOOL, csd->uaeromvector, 29, + AROS_LCA(APTR, csd->boardinfo, A0), // For current WinUAEs + AROS_LCA(APTR, csd->boardinfo, A2)); // For older E-UAEs +} + +void WaitBlitter(struct uaegfx_staticdata *csd) +{ + if (csd->CardBase) + AROS_CALL1NR(void, gptr(csd, PSSO_BoardInfo_WaitBlitter), + AROS_LCA(APTR, csd->boardinfo, A0), + struct Library*, csd->CardBase); +} + +void SetInterrupt(struct uaegfx_staticdata *csd, ULONG state) +{ + if (csd->CardBase) + AROS_CALL2(ULONG, gptr(csd, PSSO_BoardInfo_SetInterrupt), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(ULONG, state, D0), + struct Library*, csd->CardBase); +} + +ULONG GetPixelClock(struct uaegfx_staticdata *csd, struct ModeInfo *mi, ULONG index, ULONG rgbformat) +{ + if (csd->CardBase) + return AROS_CALL4(ULONG, gptr(csd, PSSO_BoardInfo_GetPixelClock), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, mi, A1), + AROS_LCA(ULONG, index, D0), + AROS_LCA(ULONG, rgbformat, D7), + struct Library*, csd->CardBase); + else + return -2; +} + +void SetMemoryMode(struct uaegfx_staticdata *csd, ULONG rgbformat) +{ + if (csd->CardBase) + AROS_CALL2(ULONG, gptr(csd, PSSO_BoardInfo_SetMemoryMode), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(ULONG, rgbformat, D7), + struct Library*, csd->CardBase); +} + +ULONG ResolvePixelClock(struct uaegfx_staticdata *csd, struct ModeInfo *mi, ULONG pixelclock, ULONG rgbformat) +{ + if (csd->CardBase) + return AROS_CALL4(ULONG, gptr(csd, PSSO_BoardInfo_ResolvePixelClock), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, mi, A1), + AROS_LCA(ULONG, pixelclock, D0), + AROS_LCA(ULONG, rgbformat, D7), + struct Library*, csd->CardBase); + else + return -2; +} +ULONG SetClock(struct uaegfx_staticdata *csd) +{ + if (csd->CardBase) + return AROS_CALL1(ULONG, gptr(csd, PSSO_BoardInfo_SetClock), + AROS_LCA(APTR, csd->boardinfo, A0), + struct Library*, csd->CardBase); + else + return -2; +} +BOOL SetDisplay(struct uaegfx_staticdata *csd, BOOL state) +{ + if (csd->CardBase) + return AROS_CALL2(BOOL, gptr(csd, PSSO_BoardInfo_SetDisplay), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(BOOL, state, D0), + struct Library*, csd->CardBase); + else + return P96_LC2(BOOL, csd->uaeromvector, 26, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(BOOL, state, D0)); +} +BOOL SetSwitch(struct uaegfx_staticdata *csd, BOOL state) +{ + if (csd->CardBase) + return AROS_CALL2(BOOL, gptr(csd, PSSO_BoardInfo_SetSwitch), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(BOOL, state, D0), + struct Library*, csd->CardBase); + else + return P96_LC2(BOOL, csd->uaeromvector, 18, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(BOOL, state, D0)); +} +void SetColorArray(struct uaegfx_staticdata *csd, UWORD start, UWORD count) +{ + if (csd->CardBase) + AROS_CALL3(BOOL, gptr(csd, PSSO_BoardInfo_SetColorArray), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(WORD, start, D0), + AROS_LCA(WORD, count, D1), + struct Library*, csd->CardBase); + else + P96_LC3(BOOL, csd->uaeromvector, 19, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(WORD, start, D0), + AROS_LCA(WORD, count, D1)); +} +void SetDAC(struct uaegfx_staticdata *csd) +{ + if (csd->CardBase) + AROS_CALL2(BOOL, gptr(csd, PSSO_BoardInfo_SetDAC), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(ULONG, csd->rgbformat, D7), + struct Library*, csd->CardBase); + else + P96_LC2(BOOL, csd->uaeromvector, 20, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(ULONG, csd->rgbformat, D7)); +} +void SetGC(struct uaegfx_staticdata *csd, struct ModeInfo *mi, BOOL border) +{ + if (csd->CardBase) + AROS_CALL3(BOOL, gptr(csd, PSSO_BoardInfo_SetGC), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, mi, A1), + AROS_LCA(BOOL, border, D0), + struct Library*, csd->CardBase); + else + P96_LC3(BOOL, csd->uaeromvector, 21, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, mi, A1), + AROS_LCA(BOOL, border, D0)); +} +void SetPanning(struct uaegfx_staticdata *csd, UBYTE *video, UWORD width, WORD x, WORD y) +{ + if (csd->CardBase) + AROS_CALL6(BOOL, gptr(csd, PSSO_BoardInfo_SetPanning), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, video, A1), + AROS_LCA(UWORD, width, D0), + AROS_LCA(WORD, x, D1), + AROS_LCA(WORD, y, D2), + AROS_LCA(ULONG, csd->rgbformat, D7), + struct Library*, csd->CardBase); + else + P96_LC6(BOOL, csd->uaeromvector, 22, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, video, A1), + AROS_LCA(UWORD, width, D0), + AROS_LCA(WORD, x, D1), + AROS_LCA(WORD, y, D2), + AROS_LCA(ULONG, csd->rgbformat, D7)); +} +BOOL FillRect(struct uaegfx_staticdata *csd, struct RenderInfo *ri, WORD x, WORD y, WORD w, WORD h, ULONG pen, UBYTE mask, ULONG rgbformat) +{ + if (csd->CardBase) { + AROS_CALL9(BOOL, gptr(csd, PSSO_BoardInfo_FillRect), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, ri, A1), + AROS_LCA(WORD, x, D0), + AROS_LCA(WORD, y, D1), + AROS_LCA(WORD, w, D2), + AROS_LCA(WORD, h, D3), + AROS_LCA(ULONG, pen, D4), + AROS_LCA(UBYTE, mask, D5), + AROS_LCA(ULONG, rgbformat, D7), + struct Library*, csd->CardBase); + return gw (csd->boardinfo + PSSO_BoardInfo_AROSFlag); + } else + return P96_LC9(BOOL, csd->uaeromvector, 17, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, ri, A1), + AROS_LCA(WORD, x, D0), + AROS_LCA(WORD, y, D1), + AROS_LCA(WORD, w, D2), + AROS_LCA(WORD, h, D3), + AROS_LCA(ULONG, pen, D4), + AROS_LCA(UBYTE, mask, D5), + AROS_LCA(ULONG, rgbformat, D7)); +} +BOOL InvertRect(struct uaegfx_staticdata *csd, struct RenderInfo *ri, WORD x, WORD y, WORD w, WORD h, UBYTE mask, ULONG rgbformat) +{ + if (csd->CardBase) { + AROS_CALL8(BOOL, gptr(csd, PSSO_BoardInfo_InvertRect), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, ri, A1), + AROS_LCA(WORD, x, D0), + AROS_LCA(WORD, y, D1), + AROS_LCA(WORD, w, D2), + AROS_LCA(WORD, h, D3), + AROS_LCA(UBYTE, mask, D4), + AROS_LCA(ULONG, rgbformat, D7), + struct Library*, csd->CardBase); + return gw (csd->boardinfo + PSSO_BoardInfo_AROSFlag); + } else + return P96_LC8(BOOL, csd->uaeromvector, 31, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, ri, A1), + AROS_LCA(WORD, x, D0), + AROS_LCA(WORD, y, D1), + AROS_LCA(WORD, w, D2), + AROS_LCA(WORD, h, D3), + AROS_LCA(UBYTE, mask, D4), + AROS_LCA(ULONG, rgbformat, D7)); +} +BOOL BlitRectNoMaskComplete(struct uaegfx_staticdata *csd, struct RenderInfo *risrc, struct RenderInfo *ridst, + WORD sx, WORD sy, WORD dx, WORD dy, WORD w, WORD h, UBYTE opcode, ULONG rgbformat) +{ + if (csd->CardBase) { + AROS_CALL11(BOOL, gptr(csd, PSSO_BoardInfo_BlitRectNoMaskComplete), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, risrc, A1), + AROS_LCA(APTR, ridst, A2), + AROS_LCA(WORD, sx, D0), + AROS_LCA(WORD, sy, D1), + AROS_LCA(WORD, dx, D2), + AROS_LCA(WORD, dy, D3), + AROS_LCA(WORD, w, D4), + AROS_LCA(WORD, h, D5), + AROS_LCA(UBYTE, opcode, D6), + AROS_LCA(ULONG, rgbformat, D7), + struct Library*, csd->CardBase); + return gw (csd->boardinfo + PSSO_BoardInfo_AROSFlag); + } else + return P96_LC11(BOOL, csd->uaeromvector, 28, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, risrc, A1), + AROS_LCA(APTR, ridst, A2), + AROS_LCA(WORD, sx, D0), + AROS_LCA(WORD, sy, D1), + AROS_LCA(WORD, dx, D2), + AROS_LCA(WORD, dy, D3), + AROS_LCA(WORD, w, D4), + AROS_LCA(WORD, h, D5), + AROS_LCA(UBYTE, opcode, D6), + AROS_LCA(ULONG, rgbformat, D7)); +}; +BOOL BlitPattern(struct uaegfx_staticdata *csd, struct RenderInfo *ri, struct Pattern *pat, + WORD x, WORD y, WORD w, WORD h, UBYTE mask, ULONG rgbformat) +{ + if (csd->CardBase) { + AROS_CALL9(BOOL, gptr(csd, PSSO_BoardInfo_BlitPattern), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, ri, A1), + AROS_LCA(APTR, pat, A2), + AROS_LCA(WORD, x, D0), + AROS_LCA(WORD, y, D1), + AROS_LCA(WORD, w, D2), + AROS_LCA(WORD, h, D3), + AROS_LCA(UBYTE, mask, D4), + AROS_LCA(ULONG, rgbformat, D7), + struct Library*, csd->CardBase); + return gw (csd->boardinfo + PSSO_BoardInfo_AROSFlag); + } else + return P96_LC9(BOOL, csd->uaeromvector, 30, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, ri, A1), + AROS_LCA(APTR, pat, A2), + AROS_LCA(WORD, x, D0), + AROS_LCA(WORD, y, D1), + AROS_LCA(WORD, w, D2), + AROS_LCA(WORD, h, D3), + AROS_LCA(UBYTE, mask, D4), + AROS_LCA(ULONG, rgbformat, D7)); +} + +BOOL BlitTemplate(struct uaegfx_staticdata *csd, struct RenderInfo *ri, struct Template *tmpl, + WORD x, WORD y, WORD w, WORD h, UBYTE mask, ULONG rgbformat) +{ + if (csd->CardBase) { + AROS_CALL9(BOOL, gptr(csd, PSSO_BoardInfo_BlitTemplate), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, ri, A1), + AROS_LCA(APTR, tmpl, A2), + AROS_LCA(WORD, x, D0), + AROS_LCA(WORD, y, D1), + AROS_LCA(WORD, w, D2), + AROS_LCA(WORD, h, D3), + AROS_LCA(UBYTE, mask, D4), + AROS_LCA(ULONG, rgbformat, D7), + struct Library*, csd->CardBase); + return gw (csd->boardinfo + PSSO_BoardInfo_AROSFlag); + } else + return P96_LC9(BOOL, csd->uaeromvector, 27, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(APTR, ri, A1), + AROS_LCA(APTR, tmpl, A2), + AROS_LCA(WORD, x, D0), + AROS_LCA(WORD, y, D1), + AROS_LCA(WORD, w, D2), + AROS_LCA(WORD, h, D3), + AROS_LCA(UBYTE, mask, D4), + AROS_LCA(ULONG, rgbformat, D7)); +} + +WORD CalculateBytesPerRow(struct uaegfx_staticdata *csd, WORD width, ULONG rgbformat) +{ + if (csd->CardBase) + return AROS_CALL3(BOOL, gptr(csd, PSSO_BoardInfo_CalculateBytesPerRow), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(UWORD, width, D0), + AROS_LCA(ULONG, rgbformat, D7), + struct Library*, csd->CardBase); + else + return P96_LC3(BOOL, csd->uaeromvector, 23, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(UWORD, width, D0), + AROS_LCA(ULONG, rgbformat, D7)); +} + +BOOL SetSprite(struct uaegfx_staticdata *csd, BOOL activate) +{ + if (csd->CardBase) + return AROS_CALL3(BOOL, gptr(csd, PSSO_BoardInfo_SetSprite), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(BOOL, activate, D0), + AROS_LCA(ULONG, csd->rgbformat, D7), + struct Library*, csd->CardBase); + return P96_LC3(BOOL, csd->uaeromvector, 36, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(BOOL, activate, D0), + AROS_LCA(ULONG, csd->rgbformat, D7)); +} + +BOOL SetSpritePosition(struct uaegfx_staticdata *csd) +{ + if (csd->CardBase) + return AROS_CALL2(BOOL, gptr(csd, PSSO_BoardInfo_SetSpritePosition), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(ULONG, csd->rgbformat, D7), + struct Library*, csd->CardBase); + return P96_LC2(BOOL, csd->uaeromvector, 37, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(ULONG, csd->rgbformat, D7)); +} + +BOOL SetSpriteImage(struct uaegfx_staticdata *csd) +{ + if (csd->CardBase) + return AROS_CALL2(BOOL, gptr(csd, PSSO_BoardInfo_SetSpriteImage), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(ULONG, csd->rgbformat, D7), + struct Library*, csd->CardBase); + return P96_LC2(BOOL, csd->uaeromvector, 38, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(ULONG, csd->rgbformat, D7)); +} + +BOOL SetSpriteColor(struct uaegfx_staticdata *csd, UBYTE idx, UBYTE r, UBYTE g, UBYTE b) +{ + if (csd->CardBase) + return AROS_CALL6(BOOL, gptr(csd, PSSO_BoardInfo_SetSpriteColor), + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(UBYTE, idx, D0), + AROS_LCA(UBYTE, r, D1), + AROS_LCA(UBYTE, g, D2), + AROS_LCA(UBYTE, b, D3), + AROS_LCA(ULONG, csd->rgbformat, D7), + struct Library*, csd->CardBase); + return P96_LC6(BOOL, csd->uaeromvector, 39, + AROS_LCA(APTR, csd->boardinfo, A0), + AROS_LCA(UBYTE, idx, D0), + AROS_LCA(UBYTE, r, D1), + AROS_LCA(UBYTE, g, D2), + AROS_LCA(UBYTE, b, D3), + AROS_LCA(ULONG, csd->rgbformat, D7)); +} + +WORD getrtgdepth(ULONG rgbformat) +{ + if (rgbformat & RGBFF_CLUT) + return 8; + if (rgbformat & (RGBFF_R5G5B5PC | RGBFF_R5G5B5 | RGBFF_B5G5R5PC)) + return 15; + if (rgbformat & (RGBFF_R5G6B5PC | RGBFF_R5G6B5 | RGBFF_B5G6R5PC)) + return 16; + if (rgbformat & (RGBFF_R8G8B8 | RGBFF_B8G8R8)) + return 24; + if (rgbformat & (RGBFF_A8R8G8B8 | RGBFF_A8B8G8R8 | RGBFF_R8G8B8A8 | RGBFF_B8G8R8A8)) + return 32; + return 0; +} + +ULONG getrtgformat(struct uaegfx_staticdata *csd, OOP_Object *pixfmt) +{ + IPTR depth, redmask, bluemask, endianswitch; + + OOP_GetAttr(pixfmt, aHidd_PixFmt_Depth, &depth); + OOP_GetAttr(pixfmt, aHidd_PixFmt_RedMask, &redmask); + OOP_GetAttr(pixfmt, aHidd_PixFmt_BlueMask, &bluemask); + OOP_GetAttr(pixfmt, aHidd_PixFmt_SwapPixelBytes, &endianswitch); + + if (depth == 8) + return RGBFB_CLUT; + if (depth == 15) { + if (redmask == 0x00007c00 && !endianswitch) + return RGBFB_R5G5B5; + if (redmask == 0x00007c00 && endianswitch) + return RGBFB_R5G5B5PC; + if (redmask == 0x0000003e && bluemask == 0x0000f800) + return RGBFB_B5G5R5PC; + } + if (depth == 16) { + if (redmask == 0x0000f800 && !endianswitch) + return RGBFB_R5G6B5; + if (redmask == 0x0000f800 && endianswitch) + return RGBFB_R5G6B5PC; + if (redmask == 0x0000001f && bluemask == 0x0000f800) + return RGBFB_B5G6R5PC; + } + if (depth == 32) { + if (redmask == 0x0000ff00) + return RGBFB_B8G8R8A8; + if (redmask == 0xff000000) + return RGBFB_R8G8B8A8; + if (redmask == 0x000000ff) + return RGBFB_A8B8G8R8; + if (redmask == 0x00ff0000) + return RGBFB_A8R8G8B8; + } else if (depth == 24) { + if (redmask == 0x000000ff) + return RGBFB_B8G8R8; + if (redmask == 0x00ff0000) + return RGBFB_R8G8B8; + } + D(bug("getrtgformat RGBFB_NONE!? %d %08x %08x\n", depth, redmask, bluemask)); + return RGBFB_NONE; +} + +void makerenderinfo(struct uaegfx_staticdata *csd, struct RenderInfo *ri, struct bm_data *bm) +{ + ri->Memory = bm->VideoData; + ri->BytesPerRow = bm->bytesperline; + ri->RGBFormat = bm->rgbformat; +} + +struct ModeInfo *getrtgmodeinfo(struct uaegfx_staticdata *csd, OOP_Object *sync, OOP_Object *pixfmt, struct ModeInfo *modeinfo) +{ + struct LibResolution *node; + IPTR width, height, depth; + + OOP_GetAttr(sync, aHidd_Sync_HDisp, &width); + OOP_GetAttr(sync, aHidd_Sync_VDisp, &height); + OOP_GetAttr(pixfmt, aHidd_PixFmt_Depth, &depth); + + D(bug("getrtgmodeinfo %dx%dx%d\n", width, height, depth)); + // UAE RTG driver does not need anything else + // but real RTG does + ForeachNode((csd->boardinfo + PSSO_BoardInfo_ResolutionsList), node) { + if (node->Width == width && node->Height == height) { + UBYTE index = (depth + 7) / 8; + if (node->Modes[index]) { + D(bug("RTG ModeInfo found %p\n", node->Modes[index])); + return node->Modes[index]; + } + } + } + D(bug("using fake modeinfo\n")); + modeinfo->Width = width; + modeinfo->Height = height; + modeinfo->Depth = depth; + return modeinfo; +} + +const UBYTE modetable[16] = + { 0, 8, 4, 12, 2, 10, 6, 14, 7, 9, 5, 13, 3, 11, 1, 15 }; + +APTR gp(UBYTE *p) +{ + return ((APTR*)p)[0]; +} +ULONG gl(UBYTE *p) +{ + return ((ULONG*)p)[0]; +} +UWORD gw(UBYTE *p) +{ + return ((UWORD*)p)[0]; +} +void pp(UBYTE *p, APTR a) +{ + ((APTR*)p)[0] = a; +} +void pl(UBYTE *p, ULONG l) +{ + ((ULONG*)p)[0] = l; +} +void pw(UBYTE *p, WORD w) +{ + ((WORD*)p)[0] = w; +} +void pb(UBYTE *p, BYTE b) +{ + ((BYTE*)p)[0] = b; +} diff --git a/arch/m68k-amiga/hidd/p96gfx/p96gfx_rtg.h b/arch/m68k-amiga/hidd/uaegfx/uaertg.h similarity index 77% rename from arch/m68k-amiga/hidd/p96gfx/p96gfx_rtg.h rename to arch/m68k-amiga/hidd/uaegfx/uaertg.h index 1a19a91add..42e15f2a61 100644 --- a/arch/m68k-amiga/hidd/p96gfx/p96gfx_rtg.h +++ b/arch/m68k-amiga/hidd/uaegfx/uaertg.h @@ -1,5 +1,5 @@ -#ifndef P96GFX_P96RTG_H -#define P96GFX_P96RTG_H +#ifndef UAEGFX_UAERTG_H +#define UAEGFX_UAERTG_H /* Types for RGBFormat used */ typedef enum { @@ -71,22 +71,14 @@ typedef enum { RGBFF_A8R8G8B8 | RGBFF_A8B8G8R8 | RGBFF_R8G8B8A8 | RGBFF_B8G8R8A8 | RGBFF_B8G8R8 | RGBFF_R8G8B8 | \ RGBFF_R5G6B5 | RGBFF_R5G5B5 | RGBFF_R5G6B5PC | RGBFF_R5G5B5PC | RGBFF_B5G6R5PC | RGBFF_B5G5R5PC) -/* BoardInfo hardare flags (set by the driver) */ +/* BoardInfo flags */ #define BIB_HARDWARESPRITE 0 /* board has hardware sprite */ #define BIB_VBLANKINTERRUPT 4 /* board can cause a hardware interrupt on a vertical retrace */ -#define BIB_BLITTER 15 /* board has blitter */ -/* BoardInfo user flags (set by the rtg subsystem) */ +#define BIB_BLITTER 15 /* board has blitter */ #define BIB_HIRESSPRITE 16 /* mouse sprite has double resolution */ #define BIB_BIGSPRITE 17 /* user wants big mouse sprite */ #define BIB_NOBLITTER 24 /* disable all blitter functions */ -#define BIF_HARDWARESPRITE (1 << BIB_HARDWARESPRITE) -#define BIF_VBLANKINTERRUPT (1 << BIB_VBLANKINTERRUPT) -#define BIF_BLITTER (1 << BIB_BLITTER) -#define BIF_HIRESSPRITE (1 << BIB_HIRESSPRITE) -#define BIF_BIGSPRITE (1 << BIB_BIGSPRITE) -#define BIF_NOBLITTER (1 << BIB_NOBLITTER) - enum { PLANAR, CHUNKY, @@ -140,20 +132,6 @@ struct Pattern { UBYTE DrawMode; }; -struct Line { - WORD X, Y; - UWORD Length; - WORD dX, dY; - WORD sDelta, lDelta, twoSDminusLD; - UWORD LinePtrn; - UWORD PatternShift; - ULONG FgPen, BgPen; - BOOL Horizontal; - UBYTE DrawMode; - BYTE pad; - UWORD Xorigin, Yorigin; -}; - struct ModeInfo { struct Node Node; WORD OpenCount; @@ -368,114 +346,55 @@ struct ModeInfo { #define PSSO_BoardInfo_SyncTime PSSO_BoardInfo_DoubleBufferList + 4 #define PSSO_BoardInfo_SyncPeriod PSSO_BoardInfo_SyncTime + 4 #define PSSO_BoardInfo_SoftVBlankPort PSSO_BoardInfo_SyncPeriod + 8 -#define PSSO_BoardInfo_WaitQ PSSO_BoardInfo_SyncPeriod + 34 -#define PSSO_BoardInfo_AROSFlag PSSO_BoardInfo_WaitQ + 12 +#define PSSO_BoardInfo_WaitQ PSSO_BoardInfo_SyncPeriod + 34 +#define PSSO_BoardInfo_AROSFlag PSSO_BoardInfo_WaitQ + 12 #define PSSO_BoardInfo_SizeOf PSSO_BoardInfo_AROSFlag + 4 -#define P96BoardType_PicassoII 6 -#define P96BoardType_Piccolo 7 -#define P96BoardType_RetinaBLT 8 -#define P96BoardType_PicassoIV 10 -#define P96BoardType_PiccoloSD64 11 -#define P96BoardType_A2410 12 -#define P96BoardType_Pixel64 13 -#define P96BoardType_UAEGfx 14 -#define P96BoardType_Vampire 25 - -/* inline access wrappers */ -static inline APTR gp(UBYTE *p) -{ - return ((APTR*)p)[0]; -} -static inline ULONG gl(UBYTE *p) -{ - return ((ULONG*)p)[0]; -} -static inline UWORD gw(UBYTE *p) -{ - return ((UWORD*)p)[0]; -} -static inline void pp(UBYTE *p, APTR a) -{ - ((APTR*)p)[0] = a; -} -static inline void pl(UBYTE *p, ULONG l) -{ - ((ULONG*)p)[0] = l; -} -static inline void pw(UBYTE *p, WORD w) -{ - ((WORD*)p)[0] = w; -} -static inline void pb(UBYTE *p, BYTE b) -{ - ((BYTE*)p)[0] = b; -} - -struct P96GfxBitMapData; - -/* RTG Support functions */ +WORD getrtgdepth (ULONG rgbformat); +ULONG getrtgformat(struct uaegfx_staticdata *csd, OOP_Object *); +void makerenderinfo(struct uaegfx_staticdata *csd, struct RenderInfo*, struct bm_data*); +struct ModeInfo *getrtgmodeinfo(struct uaegfx_staticdata *csd, OOP_Object *sync, OOP_Object *pixfmt, struct ModeInfo *modeinfo); + +APTR gp(UBYTE *p); +ULONG gl(UBYTE *p); +UWORD gw(UBYTE *p); +void pp(UBYTE *p, APTR a); +void pl(UBYTE *p, ULONG l); +void pw(UBYTE *p, WORD w); +void pb(UBYTE *p, BYTE b); + extern const UBYTE modetable[16]; -WORD P96GFXRTG__GetDepth (ULONG rgbformat); -ULONG P96GFXRTG__GetFormat(struct p96gfx_staticdata *csd, struct p96gfx_carddata *cid, OOP_Object *); -void P96GFXRTG__MakeRenderInfo(struct p96gfx_staticdata *csd, struct p96gfx_carddata *cid, struct RenderInfo*, struct P96GfxBitMapData*); -struct ModeInfo *P96GFXRTG__GetModeInfo(struct p96gfx_staticdata *csd, struct p96gfx_carddata *cid, OOP_Object *sync, OOP_Object *pixfmt, struct ModeInfo *modeinfo); -void P96GFXRTG__Init(APTR boardinfo); - -/* Card functions */ -BOOL FindCard(struct p96gfx_carddata *cid); -BOOL InitCard(struct p96gfx_carddata *cid); -BOOL SetDisplay(struct p96gfx_carddata *cid, BOOL state); -BOOL SetSwitch(struct p96gfx_carddata *cid, BOOL state); -void SetColorArray(struct p96gfx_carddata *cid, UWORD start, UWORD count); -void SetDAC(struct p96gfx_carddata *cid); -void SetGC(struct p96gfx_carddata *cid, struct ModeInfo *mi, BOOL border); -void SetPanning(struct p96gfx_carddata *cid, UBYTE *video, UWORD width, WORD x, WORD y); -/* -TODO: -SetDPMSLevel -GetFeatureAttrs -SetFeatureAttrs -*/ - -/* Card Render Operation Stubs .. */ -BOOL DrawLine(struct p96gfx_carddata *cid, struct RenderInfo *ri, - struct Line *line, ULONG rgbformat); -BOOL BlitRect(struct p96gfx_carddata *cid, struct RenderInfo *ri, - WORD sx, WORD sy, WORD dx, WORD dy, WORD w, WORD h, UBYTE mask, ULONG rgbformat); -BOOL FillRect(struct p96gfx_carddata *cid, struct RenderInfo *ri, WORD x, WORD y, WORD w, WORD h, ULONG pen, UBYTE mask, ULONG rgbformat); -BOOL InvertRect(struct p96gfx_carddata *cid, struct RenderInfo *ri, WORD x, WORD y, WORD w, WORD h, UBYTE mask, ULONG rgbformat); -BOOL BlitRectNoMaskComplete(struct p96gfx_carddata *cid, struct RenderInfo *risrc, struct RenderInfo *ridst, +BOOL FindCard(struct uaegfx_staticdata *csd); +BOOL InitCard(struct uaegfx_staticdata *csd); +BOOL SetDisplay(struct uaegfx_staticdata *csd, BOOL state); +BOOL SetSwitch(struct uaegfx_staticdata *csd, BOOL state); +void SetColorArray(struct uaegfx_staticdata *csd, UWORD start, UWORD count); +void SetDAC(struct uaegfx_staticdata *csd); +void SetGC(struct uaegfx_staticdata *csd, struct ModeInfo *mi, BOOL border); +void SetPanning(struct uaegfx_staticdata *csd, UBYTE *video, UWORD width, WORD x, WORD y); +BOOL FillRect(struct uaegfx_staticdata *csd, struct RenderInfo *ri, WORD x, WORD y, WORD w, WORD h, ULONG pen, UBYTE mask, ULONG rgbformat); +BOOL InvertRect(struct uaegfx_staticdata *csd, struct RenderInfo *ri, WORD x, WORD y, WORD w, WORD h, UBYTE mask, ULONG rgbformat); +BOOL BlitRectNoMaskComplete(struct uaegfx_staticdata *csd, struct RenderInfo *risrc, struct RenderInfo *ridst, WORD sx, WORD sy, WORD dx, WORD dy, WORD w, WORD h, UBYTE opcode, ULONG rgbformat); -BOOL BlitPattern(struct p96gfx_carddata *cid, struct RenderInfo *ri, struct Pattern *pat, +BOOL BlitPattern(struct uaegfx_staticdata *csd, struct RenderInfo *ri, struct Pattern *pat, WORD x, WORD y, WORD w, WORD h, UBYTE mask, ULONG rgbformat); -BOOL BlitTemplate(struct p96gfx_carddata *cid, struct RenderInfo *ri, struct Template *tmpl, +BOOL BlitTemplate(struct uaegfx_staticdata *csd, struct RenderInfo *ri, struct Template *tmpl, WORD x, WORD y, WORD w, WORD h, UBYTE mask, ULONG rgbformat); -/* -TODO: -BlitPlanar2Chunky -BlitPlanar2Direct -WriteYUVRect -*/ - -WORD CalculateBytesPerRow(struct p96gfx_carddata *cid, WORD width, ULONG rgbformat); -BOOL SetSprite(struct p96gfx_carddata *cid, BOOL activate); -BOOL SetSpritePosition(struct p96gfx_carddata *cid); -BOOL SetSpriteImage(struct p96gfx_carddata *cid); -BOOL SetSpriteColor(struct p96gfx_carddata *cid, UBYTE idx, UBYTE r, UBYTE g, UBYTE b); - -/* Real RTG only card functions */ -ULONG GetPixelClock(struct p96gfx_carddata *cid, struct ModeInfo *mi, ULONG index, ULONG rgbformat); -ULONG ResolvePixelClock(struct p96gfx_carddata *cid, struct ModeInfo *mi, ULONG pixelclock, ULONG rgbformat); -ULONG SetClock(struct p96gfx_carddata *cid); -void SetMemoryMode(struct p96gfx_carddata *cid, ULONG rgbformat); -void WaitBlitter(struct p96gfx_carddata *cid); -void SetInterrupt(struct p96gfx_carddata *cid, ULONG state); -/* -TODO: -GetVSyncState -WaitVerticalSync -GetVBeamPos -*/ + +WORD CalculateBytesPerRow(struct uaegfx_staticdata *csd, WORD width, ULONG rgbformat); +BOOL SetSprite(struct uaegfx_staticdata *sd, BOOL activate); +BOOL SetSpritePosition(struct uaegfx_staticdata *sd); +BOOL SetSpriteImage(struct uaegfx_staticdata *sd); +BOOL SetSpriteColor(struct uaegfx_staticdata *sd, UBYTE idx, UBYTE r, UBYTE g, UBYTE b); + +/* real RTG only functions */ +ULONG GetPixelClock(struct uaegfx_staticdata *csd, struct ModeInfo *mi, ULONG index, ULONG rgbformat); +ULONG ResolvePixelClock(struct uaegfx_staticdata *csd, struct ModeInfo *mi, ULONG pixelclock, ULONG rgbformat); +ULONG SetClock(struct uaegfx_staticdata *csd); +void SetMemoryMode(struct uaegfx_staticdata *csd, ULONG rgbformat); +void WaitBlitter(struct uaegfx_staticdata *csd); +void SetInterrupt(struct uaegfx_staticdata *csd, ULONG state); +void InitRTG(APTR boardinfo); + #endif diff --git a/arch/x86_64-pc/boot/grub2/grub-efi.cfg b/arch/x86_64-pc/boot/grub2/grub-efi.cfg index d07723a623..03cbaa0bf2 100644 --- a/arch/x86_64-pc/boot/grub2/grub-efi.cfg +++ b/arch/x86_64-pc/boot/grub2/grub-efi.cfg @@ -3,7 +3,7 @@ insmod efi_gop insmod efi_uga -if loadfont /EFI/BOOT/grub/fonts/unicode.pf2 ; then +if loadfont /EFI/BOOT/grub/unicode.pf2 ; then insmod gfxterm set gfxmode=640x480 terminal_output gfxterm diff --git a/arch/x86_64-pc/boot/grub2/grub.cfg b/arch/x86_64-pc/boot/grub2/grub.cfg index 965991f20e..a81274557d 100644 --- a/arch/x86_64-pc/boot/grub2/grub.cfg +++ b/arch/x86_64-pc/boot/grub2/grub.cfg @@ -1,4 +1,4 @@ -if loadfont /boot/pc/grub/fonts/unicode.pf2 ; then +if loadfont /boot/pc/grub/unicode.pf2 ; then insmod vbe insmod gfxterm set gfxmode=640x480 -- 2.11.4.GIT