Mercurial > sdl-ios-xcode
view src/hermes/x86_main.asm @ 1211:304d8dd6a989
To: sdl@libsdl.org
From: Christian Walther <cwalther@gmx.ch>
Date: Wed, 28 Dec 2005 12:13:20 +0100
Subject: [SDL] Fix for opening documents on Mac OS X < 10.4
The current code in SDLMain.m that transforms documents opened from the
Finder into command-line arguments (introduced in revision 1.14,
2005-08-11) uses the methods -[NSString lengthOfBytesUsingEncoding:] and
-[NSString getCString:maxLength:encoding:], which are only available in
Mac OS X 10.4.
Compiling this code on 10.3 produces warnings, and running it (i.e.
starting an SDL application by opening a document) leads to weird
behavior which I didn't investigate in detail ("*** -[NSCFString
lengthOfBytesUsingEncoding:]: selector not recognized" is printed to the
console log, and the SDL window never opens).
The attached patch removes the offending calls and uses -[NSString
UTF8String] instead, which is available everywhere. Tested on 10.3.9,
and I see no reason why it shouldn't also work on 10.2 and 10.4.
Two further comments:
* The comment above the -[SDLMain application: openFile:] implementation
says "You need to have a CFBundleDocumentsType section in your
Info.plist to get this message, apparently." This is not the case in my
experience - it worked just fine with a hand-built bare-bones
application consisting only of Test.app/Contents/MacOS/test, without any
Info.plist (although you have to press the option and command keys for
such an application to accept a dragged file).
* I took the liberty of cleaning up another area of SDLMain.m: I changed
"CustomApplicationMain (argc, argv)" to "CustomApplicationMain (int
argc, char **argv)". This avoids the "type of `argv' defaults to `int'"
warnings, and I'm not sure if leaving out the types could cause problems
on platforms where an int and a char** aren't of the same size.
-Christian
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sun, 01 Jan 2006 23:45:52 +0000 |
parents | 2d6dc7de1145 |
children | 3202d727bb4b |
line wrap: on
line source
; ; x86 format converters for HERMES ; Some routines Copyright (c) 1998 Christian Nentwich (brn@eleet.mcb.at) ; This source code is licensed under the GNU LGPL ; ; Please refer to the file COPYING.LIB contained in the distribution for ; licensing conditions ; ; Most routines are (c) Glenn Fiedler (ptc@gaffer.org), used with permission ; BITS 32 GLOBAL _ConvertX86 GLOBAL _x86return GLOBAL _Hermes_X86_CPU SECTION .data cpu_flags dd 0 SECTION .text ;; _ConvertX86: ;; [ESP+8] ConverterInfo* ;; -------------------------------------------------------------------------- ;; ConverterInfo (ebp+..) ;; 0: void *s_pixels ;; 4: int s_width ;; 8: int s_height ;; 12: int s_add ;; 16: void *d_pixels ;; 20: int d_width ;; 24: int d_height ;; 28: int d_add ;; 32: void (*converter_function)() ;; 36: int32 *lookup _ConvertX86: push ebp mov ebp,esp ; Save the registers used by the blitters, necessary for optimized code pusha mov eax,[ebp+8] cmp dword [eax+4],BYTE 0 je endconvert mov ebp,eax mov esi,[ebp+0] mov edi,[ebp+16] y_loop: mov ecx,[ebp+4] jmp [ebp+32] _x86return: add esi,[ebp+12] add edi,[ebp+28] dec dword [ebp+8] jnz y_loop ; Restore the registers used by the blitters, necessary for optimized code popa pop ebp endconvert: ret ;; Hermes_X86_CPU returns the CPUID flags in eax _Hermes_X86_CPU: pushfd pop eax mov ecx,eax xor eax,040000h push eax popfd pushfd pop eax xor eax,ecx jz .L1 ; Processor is 386 push ecx popfd mov eax,ecx xor eax,200000h push eax popfd pushfd pop eax xor eax,ecx je .L1 pusha mov eax,1 cpuid mov [cpu_flags],edx popa mov eax,[cpu_flags] .L1: ret %ifidn __OUTPUT_FORMAT__,elf section .note.GNU-stack noalloc noexec nowrite progbits %endif